pipewire: allow NULL pointers in pw_properties_free()

Just like the real free() we should just ignore a NULL pointer, makes the
caller code easier for those instances where properties are optional.

Patch generated with concinelle with a few manual fixes.
This commit is contained in:
Peter Hutterer 2021-06-01 11:21:17 +10:00 committed by Wim Taymans
parent a1e821c259
commit e0471c6757
68 changed files with 142 additions and 273 deletions

View file

@ -1078,8 +1078,7 @@ static int snd_pcm_pipewire_open(snd_pcm_t **pcmp, const char *name,
return 0; return 0;
error: error:
if (props) pw_properties_free(props);
pw_properties_free(props);
snd_pcm_pipewire_free(pw); snd_pcm_pipewire_free(pw);
return err; return err;
} }

View file

@ -1157,10 +1157,8 @@ int sm_alsa_monitor_start(struct sm_media_session *session)
out_free: out_free:
if (impl->handle) if (impl->handle)
pw_unload_spa_handle(impl->handle); pw_unload_spa_handle(impl->handle);
if (impl->conf) pw_properties_free(impl->conf);
pw_properties_free(impl->conf); pw_properties_free(impl->props);
if (impl->props)
pw_properties_free(impl->props);
free(impl); free(impl);
return res; return res;
} }

View file

@ -750,10 +750,8 @@ int sm_bluez5_monitor_start(struct sm_media_session *session)
return 0; return 0;
out_free: out_free:
if (impl->conf) pw_properties_free(impl->conf);
pw_properties_free(impl->conf); pw_properties_free(impl->props);
if (impl->props)
pw_properties_free(impl->props);
free(impl); free(impl);
out: out:
return res; return res;

View file

@ -341,10 +341,8 @@ unref:
if (!obj->discarded) if (!obj->discarded)
return 0; return 0;
if (obj->props) { pw_properties_free(obj->props);
pw_properties_free(obj->props); obj->props = NULL;
obj->props = NULL;
}
spa_list_consume(d, &obj->data, link) { spa_list_consume(d, &obj->data, link) {
spa_list_remove(&d->link); spa_list_remove(&d->link);
@ -818,8 +816,7 @@ static void session_event_info(void *object, const struct pw_session_info *info)
if (info) { if (info) {
i->change_mask = info->change_mask; i->change_mask = info->change_mask;
if (info->change_mask & PW_SESSION_CHANGE_MASK_PROPS) { if (info->change_mask & PW_SESSION_CHANGE_MASK_PROPS) {
if (i->props) pw_properties_free ((struct pw_properties *)i->props);
pw_properties_free ((struct pw_properties *)i->props);
i->props = (struct spa_dict *) pw_properties_new_dict (info->props); i->props = (struct spa_dict *) pw_properties_new_dict (info->props);
} }
} }
@ -857,8 +854,7 @@ static void session_destroy(void *object)
spa_list_remove(&endpoint->link); spa_list_remove(&endpoint->link);
} }
if (i) { if (i) {
if (i->props) pw_properties_free ((struct pw_properties *)i->props);
pw_properties_free ((struct pw_properties *)i->props);
free(i); free(i);
} }
@ -898,8 +894,7 @@ static void endpoint_event_info(void *object, const struct pw_endpoint_info *inf
i->session_id = info->session_id; i->session_id = info->session_id;
} }
if (info->change_mask & PW_ENDPOINT_CHANGE_MASK_PROPS) { if (info->change_mask & PW_ENDPOINT_CHANGE_MASK_PROPS) {
if (i->props) pw_properties_free ((struct pw_properties *)i->props);
pw_properties_free ((struct pw_properties *)i->props);
i->props = (struct spa_dict *) pw_properties_new_dict (info->props); i->props = (struct spa_dict *) pw_properties_new_dict (info->props);
if ((str = spa_dict_lookup(i->props, PW_KEY_PRIORITY_SESSION)) != NULL) if ((str = spa_dict_lookup(i->props, PW_KEY_PRIORITY_SESSION)) != NULL)
endpoint->priority = pw_properties_parse_int(str); endpoint->priority = pw_properties_parse_int(str);
@ -954,8 +949,7 @@ static void endpoint_destroy(void *object)
spa_list_remove(&endpoint->link); spa_list_remove(&endpoint->link);
} }
if (i) { if (i) {
if (i->props) pw_properties_free ((struct pw_properties *)i->props);
pw_properties_free ((struct pw_properties *)i->props);
free(i->name); free(i->name);
free(i->media_class); free(i->media_class);
free(i); free(i);
@ -1321,8 +1315,7 @@ static void registry_event_free(struct registry_event *re)
{ {
if (re->proxy) if (re->proxy)
pw_proxy_destroy(re->proxy); pw_proxy_destroy(re->proxy);
if (re->props_store) pw_properties_free(re->props_store);
pw_properties_free(re->props_store);
if (re->allocated) { if (re->allocated) {
spa_list_remove(&re->link); spa_list_remove(&re->link);
free(re); free(re);

View file

@ -557,8 +557,7 @@ int sm_restore_stream_start(struct sm_media_session *session)
exit_errno: exit_errno:
res = -errno; res = -errno;
if (impl->props) pw_properties_free(impl->props);
pw_properties_free(impl->props);
free(impl); free(impl);
return res; return res;
} }

View file

@ -89,8 +89,7 @@ pw_session_info_free (struct pw_session_info *info)
struct pw_session_info info; struct pw_session_info info;
} *ext = SPA_CONTAINER_OF(info, struct extended_info, info); } *ext = SPA_CONTAINER_OF(info, struct extended_info, info);
if (ext->props_storage) pw_properties_free(ext->props_storage);
pw_properties_free(ext->props_storage);
free((void *) info->params); free((void *) info->params);
free(ext); free(ext);
} }
@ -160,8 +159,7 @@ pw_endpoint_info_free (struct pw_endpoint_info *info)
struct pw_endpoint_info info; struct pw_endpoint_info info;
} *ext = SPA_CONTAINER_OF(info, struct extended_info, info); } *ext = SPA_CONTAINER_OF(info, struct extended_info, info);
if (ext->props_storage) pw_properties_free(ext->props_storage);
pw_properties_free(ext->props_storage);
free(info->name); free(info->name);
free(info->media_class); free(info->media_class);
free((void *) info->params); free((void *) info->params);
@ -230,8 +228,7 @@ pw_endpoint_stream_info_free (struct pw_endpoint_stream_info *info)
struct pw_endpoint_stream_info info; struct pw_endpoint_stream_info info;
} *ext = SPA_CONTAINER_OF(info, struct extended_info, info); } *ext = SPA_CONTAINER_OF(info, struct extended_info, info);
if (ext->props_storage) pw_properties_free(ext->props_storage);
pw_properties_free(ext->props_storage);
free(info->name); free(info->name);
free(info->link_params); free(info->link_params);
free((void *) info->params); free((void *) info->params);
@ -304,8 +301,7 @@ pw_endpoint_link_info_free (struct pw_endpoint_link_info *info)
struct pw_endpoint_link_info info; struct pw_endpoint_link_info info;
} *ext = SPA_CONTAINER_OF(info, struct extended_info, info); } *ext = SPA_CONTAINER_OF(info, struct extended_info, info);
if (ext->props_storage) pw_properties_free(ext->props_storage);
pw_properties_free(ext->props_storage);
free(info->error); free(info->error);
free((void *) info->params); free((void *) info->params);
free(ext); free(ext);

View file

@ -274,8 +274,7 @@ static void module_destroy(void *data)
spa_hook_remove(&impl->context_listener); spa_hook_remove(&impl->context_listener);
spa_hook_remove(&impl->module_listener); spa_hook_remove(&impl->module_listener);
if (impl->properties) pw_properties_free(impl->properties);
pw_properties_free(impl->properties);
free(impl); free(impl);
} }

View file

@ -243,8 +243,7 @@ error_usage:
pw_resource_errorf_id(resource, new_id, res, "usage: "ADAPTER_USAGE); pw_resource_errorf_id(resource, new_id, res, "usage: "ADAPTER_USAGE);
goto error_cleanup; goto error_cleanup;
error_cleanup: error_cleanup:
if (properties) pw_properties_free(properties);
pw_properties_free(properties);
errno = -res; errno = -res;
return NULL; return NULL;
} }

View file

@ -300,8 +300,7 @@ struct pw_impl_node *pw_adapter_new(struct pw_context *context,
return node; return node;
error: error:
if (props) pw_properties_free(props);
pw_properties_free(props);
errno = -res; errno = -res;
return NULL; return NULL;
} }

View file

@ -497,8 +497,7 @@ do_update_port(struct node *this,
} }
if (change_mask & PW_CLIENT_NODE_PORT_UPDATE_INFO) { if (change_mask & PW_CLIENT_NODE_PORT_UPDATE_INFO) {
if (port->properties) pw_properties_free(port->properties);
pw_properties_free(port->properties);
port->properties = NULL; port->properties = NULL;
port->info.props = NULL; port->info.props = NULL;
port->info.n_params = 0; port->info.n_params = 0;
@ -1764,8 +1763,7 @@ error_exit_free:
error_exit_cleanup: error_exit_cleanup:
if (resource) if (resource)
pw_resource_destroy(resource); pw_resource_destroy(resource);
if (properties) pw_properties_free(properties);
pw_properties_free(properties);
errno = -res; errno = -res;
return NULL; return NULL;
} }

View file

@ -482,8 +482,7 @@ do_update_port(struct node *this,
} }
if (change_mask & PW_CLIENT_NODE0_PORT_UPDATE_INFO) { if (change_mask & PW_CLIENT_NODE0_PORT_UPDATE_INFO) {
if (port->properties) pw_properties_free(port->properties);
pw_properties_free(port->properties);
port->properties = NULL; port->properties = NULL;
port->info.props = NULL; port->info.props = NULL;
port->info.n_params = 0; port->info.n_params = 0;

View file

@ -462,10 +462,8 @@ static void impl_destroy(struct impl *impl)
pw_core_disconnect(impl->core); pw_core_disconnect(impl->core);
if (impl->aec) if (impl->aec)
echo_cancel_destroy(impl->aec_info, impl->aec); echo_cancel_destroy(impl->aec_info, impl->aec);
if (impl->source_props) pw_properties_free(impl->source_props);
pw_properties_free(impl->source_props); pw_properties_free(impl->sink_props);
if (impl->sink_props)
pw_properties_free(impl->sink_props);
pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID); pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID);
free(impl); free(impl);
} }
@ -647,8 +645,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
return 0; return 0;
error: error:
if (props) pw_properties_free(props);
pw_properties_free(props);
impl_destroy(impl); impl_destroy(impl);
return res; return res;
} }

View file

@ -1633,10 +1633,8 @@ static void impl_destroy(struct impl *impl)
pw_stream_destroy(impl->playback); pw_stream_destroy(impl->playback);
if (impl->core && impl->do_disconnect) if (impl->core && impl->do_disconnect)
pw_core_disconnect(impl->core); pw_core_disconnect(impl->core);
if (impl->capture_props) pw_properties_free(impl->capture_props);
pw_properties_free(impl->capture_props); pw_properties_free(impl->playback_props);
if (impl->playback_props)
pw_properties_free(impl->playback_props);
pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID); pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID);
graph_free(&impl->graph); graph_free(&impl->graph);
free(impl); free(impl);
@ -1818,8 +1816,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
return 0; return 0;
error: error:
if (props) pw_properties_free(props);
pw_properties_free(props);
impl_destroy(impl); impl_destroy(impl);
return res; return res;
} }

View file

@ -447,8 +447,7 @@ error_link_register:
pw_resource_errorf_id(resource, new_id, res, NAME": can't register link: %s", spa_strerror(res)); pw_resource_errorf_id(resource, new_id, res, NAME": can't register link: %s", spa_strerror(res));
goto error_exit; goto error_exit;
error_exit: error_exit:
if (properties) pw_properties_free(properties);
pw_properties_free(properties);
errno = -res; errno = -res;
return NULL; return NULL;
} }

View file

@ -307,10 +307,8 @@ static void impl_destroy(struct impl *impl)
pw_stream_destroy(impl->playback); pw_stream_destroy(impl->playback);
if (impl->core && impl->do_disconnect) if (impl->core && impl->do_disconnect)
pw_core_disconnect(impl->core); pw_core_disconnect(impl->core);
if (impl->capture_props) pw_properties_free(impl->capture_props);
pw_properties_free(impl->capture_props); pw_properties_free(impl->playback_props);
if (impl->playback_props)
pw_properties_free(impl->playback_props);
pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID); pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID);
free(impl); free(impl);
} }
@ -473,8 +471,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
return 0; return 0;
error: error:
if (props) pw_properties_free(props);
pw_properties_free(props);
impl_destroy(impl); impl_destroy(impl);
return res; return res;
} }

View file

@ -110,8 +110,7 @@ static void module_destroy(void *data)
spa_dbus_connection_destroy(impl->conn); spa_dbus_connection_destroy(impl->conn);
if (impl->properties) pw_properties_free(impl->properties);
pw_properties_free(impl->properties);
free(impl); free(impl);
} }

View file

@ -332,8 +332,7 @@ static void module_destroy(void *data)
spa_hook_remove(&impl->module_listener); spa_hook_remove(&impl->module_listener);
if (impl->properties) pw_properties_free(impl->properties);
pw_properties_free(impl->properties);
free(impl); free(impl);
} }

View file

@ -400,8 +400,7 @@ struct format_info {
static void format_info_clear(struct format_info *info) static void format_info_clear(struct format_info *info)
{ {
if (info->props) pw_properties_free(info->props);
pw_properties_free(info->props);
spa_zero(*info); spa_zero(*info);
} }

View file

@ -194,8 +194,7 @@ static void object_destroy(struct object *o)
m->this.n_objects--; m->this.n_objects--;
if (o->this.proxy) if (o->this.proxy)
pw_proxy_destroy(o->this.proxy); pw_proxy_destroy(o->this.proxy);
if (o->this.props) pw_properties_free(o->this.props);
pw_properties_free(o->this.props);
if (o->this.message_object_path) if (o->this.message_object_path)
free(o->this.message_object_path); free(o->this.message_object_path);
clear_params(&o->this.param_list, SPA_ID_INVALID); clear_params(&o->this.param_list, SPA_ID_INVALID);

View file

@ -83,8 +83,7 @@ static void module_free(struct module *module)
pw_work_queue_cancel(impl->work_queue, module, SPA_ID_INVALID); pw_work_queue_cancel(impl->work_queue, module, SPA_ID_INVALID);
free((char*)module->name); free((char*)module->name);
free((char*)module->args); free((char*)module->args);
if (module->props) pw_properties_free(module->props);
pw_properties_free(module->props);
free(module); free(module);
} }

View file

@ -461,8 +461,7 @@ struct module *create_module_combine_sink(struct impl *impl, const char *argumen
return module; return module;
out: out:
if (props) pw_properties_free(props);
pw_properties_free(props);
if (sink_names) if (sink_names)
pw_free_strv(sink_names); pw_free_strv(sink_names);
errno = -res; errno = -res;

View file

@ -233,12 +233,9 @@ struct module *create_module_ladspa_sink(struct impl *impl, const char *argument
return module; return module;
out: out:
if (props) pw_properties_free(props);
pw_properties_free(props); pw_properties_free(playback_props);
if (playback_props) pw_properties_free(capture_props);
pw_properties_free(playback_props);
if (capture_props)
pw_properties_free(capture_props);
errno = -res; errno = -res;
return NULL; return NULL;
} }

View file

@ -233,12 +233,9 @@ struct module *create_module_ladspa_source(struct impl *impl, const char *argume
return module; return module;
out: out:
if (props) pw_properties_free(props);
pw_properties_free(props); pw_properties_free(playback_props);
if (playback_props) pw_properties_free(capture_props);
pw_properties_free(playback_props);
if (capture_props)
pw_properties_free(capture_props);
errno = -res; errno = -res;
return NULL; return NULL;
} }

View file

@ -236,12 +236,9 @@ struct module *create_module_loopback(struct impl *impl, const char *argument)
return module; return module;
out: out:
if (props) pw_properties_free(props);
pw_properties_free(props); pw_properties_free(playback_props);
if (playback_props) pw_properties_free(capture_props);
pw_properties_free(playback_props);
if (capture_props)
pw_properties_free(capture_props);
errno = -res; errno = -res;
return NULL; return NULL;

View file

@ -127,8 +127,7 @@ struct module *create_module_native_protocol_tcp(struct impl *impl, const char *
return module; return module;
out: out:
if (props) pw_properties_free(props);
pw_properties_free(props);
errno = -res; errno = -res;
return NULL; return NULL;
} }

View file

@ -203,8 +203,7 @@ struct module *create_module_null_sink(struct impl *impl, const char *argument)
return module; return module;
out: out:
if (props) pw_properties_free(props);
pw_properties_free(props);
errno = -res; errno = -res;
return NULL; return NULL;
} }

View file

@ -189,8 +189,7 @@ static int module_pipesink_unload(struct client *client, struct module *module)
pw_log_info("unload module %p id:%u name:%s", module, module->idx, module->name); pw_log_info("unload module %p id:%u name:%s", module, module->idx, module->name);
if (d->capture_props != NULL) pw_properties_free(d->capture_props);
pw_properties_free(d->capture_props);
if (d->capture != NULL) if (d->capture != NULL)
pw_stream_destroy(d->capture); pw_stream_destroy(d->capture);
if (d->core != NULL) if (d->core != NULL)
@ -321,10 +320,8 @@ struct module *create_module_pipe_sink(struct impl *impl, const char *argument)
return module; return module;
out: out:
if (props) pw_properties_free(props);
pw_properties_free(props); pw_properties_free(capture_props);
if (capture_props)
pw_properties_free(capture_props);
if (filename) { if (filename) {
if (do_unlink_fifo) if (do_unlink_fifo)
unlink(filename); unlink(filename);

View file

@ -229,12 +229,9 @@ struct module *create_module_remap_sink(struct impl *impl, const char *argument)
return module; return module;
out: out:
if (props) pw_properties_free(props);
pw_properties_free(props); pw_properties_free(playback_props);
if (playback_props) pw_properties_free(capture_props);
pw_properties_free(playback_props);
if (capture_props)
pw_properties_free(capture_props);
errno = -res; errno = -res;
return NULL; return NULL;
} }

View file

@ -229,12 +229,9 @@ struct module *create_module_remap_source(struct impl *impl, const char *argumen
return module; return module;
out: out:
if (props) pw_properties_free(props);
pw_properties_free(props); pw_properties_free(playback_props);
if (playback_props) pw_properties_free(capture_props);
pw_properties_free(playback_props);
if (capture_props)
pw_properties_free(capture_props);
errno = -res; errno = -res;
return NULL; return NULL;
} }

View file

@ -187,10 +187,8 @@ struct module *create_module_simple_protocol_tcp(struct impl *impl, const char *
return module; return module;
out: out:
if (module_props) pw_properties_free(module_props);
pw_properties_free(module_props); pw_properties_free(props);
if (props)
pw_properties_free(props);
errno = -res; errno = -res;
return NULL; return NULL;
} }

View file

@ -214,10 +214,8 @@ struct module *create_module_tunnel_sink(struct impl *impl, const char *argument
return module; return module;
out: out:
if (props) pw_properties_free(props);
pw_properties_free(props); pw_properties_free(stream_props);
if (stream_props)
pw_properties_free(stream_props);
errno = -res; errno = -res;
return NULL; return NULL;
} }

View file

@ -214,10 +214,8 @@ struct module *create_module_tunnel_source(struct impl *impl, const char *argume
return module; return module;
out: out:
if (props) pw_properties_free(props);
pw_properties_free(props); pw_properties_free(stream_props);
if (stream_props)
pw_properties_free(stream_props);
errno = -res; errno = -res;
return NULL; return NULL;
} }

View file

@ -131,8 +131,7 @@ struct module *create_module_zeroconf_discover(struct impl *impl, const char *ar
return module; return module;
out: out:
if (props) pw_properties_free(props);
pw_properties_free(props);
errno = -res; errno = -res;
return NULL; return NULL;
} }

View file

@ -134,8 +134,7 @@ static void sample_free(struct sample *sample)
if (sample->index != SPA_ID_INVALID) if (sample->index != SPA_ID_INVALID)
pw_map_remove(&impl->samples, sample->index); pw_map_remove(&impl->samples, sample->index);
if (sample->props) pw_properties_free(sample->props);
pw_properties_free(sample->props);
free(sample->buffer); free(sample->buffer);
free(sample); free(sample);
} }
@ -968,8 +967,7 @@ static void stream_free(struct stream *stream)
if (stream->buffer) if (stream->buffer)
free(stream->buffer); free(stream->buffer);
if (stream->props) pw_properties_free(stream->props);
pw_properties_free(stream->props);
free(stream); free(stream);
} }
@ -1982,8 +1980,7 @@ error_invalid:
res = -EINVAL; res = -EINVAL;
goto error; goto error;
error: error:
if (props) pw_properties_free(props);
pw_properties_free(props);
if (stream) if (stream)
stream_free(stream); stream_free(stream);
return res; return res;
@ -2234,8 +2231,7 @@ error_invalid:
res = -EINVAL; res = -EINVAL;
goto error; goto error;
error: error:
if (props) pw_properties_free(props);
pw_properties_free(props);
if (stream) if (stream)
stream_free(stream); stream_free(stream);
return res; return res;
@ -2453,8 +2449,7 @@ error_toolarge:
res = -EOVERFLOW; res = -EOVERFLOW;
goto error; goto error;
error: error:
if (props != NULL) pw_properties_free(props);
pw_properties_free(props);
if (stream) if (stream)
stream_free(stream); stream_free(stream);
return res; return res;
@ -2500,8 +2495,7 @@ static int do_finish_upload_stream(struct client *client, uint32_t command, uint
event = SUBSCRIPTION_EVENT_NEW; event = SUBSCRIPTION_EVENT_NEW;
} else { } else {
if (sample->props) pw_properties_free(sample->props);
pw_properties_free(sample->props);
free(sample->buffer); free(sample->buffer);
event = SUBSCRIPTION_EVENT_CHANGE; event = SUBSCRIPTION_EVENT_CHANGE;
} }
@ -2779,8 +2773,7 @@ error_noent:
res = -ENOENT; res = -ENOENT;
goto error; goto error;
error: error:
if (props != NULL) pw_properties_free(props);
pw_properties_free(props);
return res; return res;
} }
@ -3447,8 +3440,7 @@ static int do_update_proplist(struct client *client, uint32_t command, uint32_t
} }
res = reply_simple_ack(client, tag); res = reply_simple_ack(client, tag);
exit: exit:
if (props) pw_properties_free(props);
pw_properties_free(props);
return res; return res;
error_protocol: error_protocol:
@ -3515,8 +3507,7 @@ static int do_remove_proplist(struct client *client, uint32_t command, uint32_t
} }
res = reply_simple_ack(client, tag); res = reply_simple_ack(client, tag);
exit: exit:
if (props) pw_properties_free(props);
pw_properties_free(props);
return res; return res;
error_protocol: error_protocol:
@ -6693,8 +6684,7 @@ error_free:
free(impl); free(impl);
error_exit: error_exit:
if (props != NULL) pw_properties_free(props);
pw_properties_free(props);
if (res < 0) if (res < 0)
errno = -res; errno = -res;

View file

@ -215,8 +215,7 @@ static struct sample_play *sample_play_new(struct pw_core *core,
error_cleanup: error_cleanup:
pw_stream_destroy(p->stream); pw_stream_destroy(p->stream);
error_free: error_free:
if (props) pw_properties_free(props);
pw_properties_free(props);
free(p); free(p);
errno = -res; errno = -res;
return NULL; return NULL;

View file

@ -525,8 +525,7 @@ on_connect(void *data, int fd, uint32_t mask)
return; return;
error: error:
pw_log_error(NAME" %p: failed to create client: %m", impl); pw_log_error(NAME" %p: failed to create client: %m", impl);
if (props != NULL) pw_properties_free(props);
pw_properties_free(props);
if (client != NULL) if (client != NULL)
client_free(client); client_free(client);
return; return;
@ -653,8 +652,7 @@ static void impl_free(struct impl *impl)
spa_hook_remove(&impl->module_listener); spa_hook_remove(&impl->module_listener);
spa_list_consume(s, &impl->server_list, link) spa_list_consume(s, &impl->server_list, link)
server_free(s); server_free(s);
if (impl->props) pw_properties_free(impl->props);
pw_properties_free(impl->props);
free(impl); free(impl);
} }

View file

@ -646,10 +646,8 @@ static void impl_destroy(struct impl *impl)
if (impl->core && impl->do_disconnect) if (impl->core && impl->do_disconnect)
pw_core_disconnect(impl->core); pw_core_disconnect(impl->core);
if (impl->stream_props) pw_properties_free(impl->stream_props);
pw_properties_free(impl->stream_props); pw_properties_free(impl->props);
if (impl->props)
pw_properties_free(impl->props);
pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID); pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID);
free(impl->buffer); free(impl->buffer);

View file

@ -613,8 +613,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
return 0; return 0;
error: error:
if (impl->props) pw_properties_free(impl->props);
pw_properties_free(impl->props);
if (impl->system_bus) if (impl->system_bus)
pw_rtkit_bus_free(impl->system_bus); pw_rtkit_bus_free(impl->system_bus);
free(impl); free(impl);

View file

@ -120,8 +120,7 @@ static int client_endpoint_stream_update(void *object,
: 0; : 0;
no_mem: no_mem:
if (props) pw_properties_free(props);
pw_properties_free(props);
free(stream); free(stream);
pw_log_error(NAME" %p: cannot update stream: no memory", this); pw_log_error(NAME" %p: cannot update stream: no memory", this);
pw_resource_errorf(this->resource, -ENOMEM, pw_resource_errorf(this->resource, -ENOMEM,
@ -204,8 +203,7 @@ static void *create_object(void *data,
return this; return this;
no_mem: no_mem:
if (properties) pw_properties_free(properties);
pw_properties_free(properties);
if (this && this->resource) if (this && this->resource)
pw_resource_destroy(this->resource); pw_resource_destroy(this->resource);
free(this); free(this);

View file

@ -333,6 +333,5 @@ void endpoint_stream_clear(struct endpoint_stream *this)
free(this->info.link_params); free(this->info.link_params);
free(this->info.params); free(this->info.params);
if (this->props) pw_properties_free(this->props);
pw_properties_free(this->props);
} }

View file

@ -365,6 +365,5 @@ void endpoint_clear(struct endpoint *this)
free(this->info.media_class); free(this->info.media_class);
free(this->info.params); free(this->info.params);
if (this->props) pw_properties_free(this->props);
pw_properties_free(this->props);
} }

View file

@ -119,8 +119,7 @@ static int client_session_link_update(void *object,
: 0; : 0;
no_mem: no_mem:
if (props) pw_properties_free(props);
pw_properties_free(props);
free(link); free(link);
pw_log_error(NAME" %p: cannot update link: no memory", this); pw_log_error(NAME" %p: cannot update link: no memory", this);
pw_resource_error(this->resource, -ENOMEM, pw_resource_error(this->resource, -ENOMEM,
@ -203,8 +202,7 @@ static void *create_object(void *data,
return this; return this;
no_mem: no_mem:
if (properties) pw_properties_free(properties);
pw_properties_free(properties);
if (this && this->resource) if (this && this->resource)
pw_resource_destroy(this->resource); pw_resource_destroy(this->resource);
free(this); free(this);

View file

@ -350,6 +350,5 @@ void endpoint_link_clear(struct endpoint_link *this)
free(this->info.error); free(this->info.error);
free(this->info.params); free(this->info.params);
if (this->props) pw_properties_free(this->props);
pw_properties_free(this->props);
} }

View file

@ -325,6 +325,5 @@ void session_clear(struct session *this)
free(this->info.params); free(this->info.params);
if (this->props) pw_properties_free(this->props);
pw_properties_free(this->props);
} }

View file

@ -171,8 +171,7 @@ static void impl_free(struct impl *impl)
avahi_client_free(impl->client); avahi_client_free(impl->client);
if (impl->avahi_poll) if (impl->avahi_poll)
pw_avahi_poll_free(impl->avahi_poll); pw_avahi_poll_free(impl->avahi_poll);
if (impl->properties) pw_properties_free(impl->properties);
pw_properties_free(impl->properties);
pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID); pw_work_queue_cancel(impl->work, impl, SPA_ID_INVALID);
free(impl); free(impl);
} }

View file

@ -180,8 +180,7 @@ error_bind:
goto error_exit; goto error_exit;
error_exit_cleanup: error_exit_cleanup:
if (properties) pw_properties_free(properties);
pw_properties_free(properties);
error_exit: error_exit:
free(factory_name); free(factory_name);
errno = -res; errno = -res;

View file

@ -179,8 +179,7 @@ error_bind:
goto error_exit; goto error_exit;
error_exit_cleanup: error_exit_cleanup:
if (properties) pw_properties_free(properties);
pw_properties_free(properties);
error_exit: error_exit:
errno = -res; errno = -res;
return NULL; return NULL;

View file

@ -158,7 +158,6 @@ error_exit_unload:
pw_unload_spa_handle(handle); pw_unload_spa_handle(handle);
error_exit: error_exit:
errno = -res; errno = -res;
if (properties) pw_properties_free(properties);
pw_properties_free(properties);
return NULL; return NULL;
} }

View file

@ -281,8 +281,7 @@ struct pw_impl_node *pw_spa_node_load(struct pw_context *context,
error_exit_unload: error_exit_unload:
pw_unload_spa_handle(handle); pw_unload_spa_handle(handle);
error_exit: error_exit:
if (properties) pw_properties_free(properties);
pw_properties_free(properties);
errno = -res; errno = -res;
return NULL; return NULL;
} }

View file

@ -386,10 +386,8 @@ error_free_loop:
error_free: error_free:
free(this); free(this);
error_cleanup: error_cleanup:
if (conf) pw_properties_free(conf);
pw_properties_free(conf); pw_properties_free(properties);
if (properties)
pw_properties_free(properties);
errno = -res; errno = -res;
return NULL; return NULL;
} }

View file

@ -391,8 +391,7 @@ error_proxy:
exit_free: exit_free:
free(p); free(p);
exit_cleanup: exit_cleanup:
if (properties) pw_properties_free(properties);
pw_properties_free(properties);
errno = -res; errno = -res;
return NULL; return NULL;
} }

View file

@ -1056,8 +1056,7 @@ filter_new(struct pw_context *context, const char *name,
error_properties: error_properties:
free(impl); free(impl);
error_cleanup: error_cleanup:
if (props) pw_properties_free(props);
pw_properties_free(props);
errno = -res; errno = -res;
return NULL; return NULL;
} }
@ -1124,8 +1123,7 @@ pw_filter_new_simple(struct pw_loop *loop,
error_cleanup: error_cleanup:
if (context) if (context)
pw_context_destroy(context); pw_context_destroy(context);
if (props) pw_properties_free(props);
pw_properties_free(props);
errno = -res; errno = -res;
return NULL; return NULL;
} }
@ -1509,8 +1507,7 @@ error_free:
clear_params(impl, p, SPA_ID_INVALID); clear_params(impl, p, SPA_ID_INVALID);
free(p); free(p);
error_cleanup: error_cleanup:
if (props) pw_properties_free(props);
pw_properties_free(props);
return NULL; return NULL;
} }

View file

@ -110,8 +110,7 @@ pw_global_new(struct pw_context *context,
error_free: error_free:
free(impl); free(impl);
error_cleanup: error_cleanup:
if (properties) pw_properties_free(properties);
pw_properties_free(properties);
errno = -res; errno = -res;
return NULL; return NULL;
} }

View file

@ -447,8 +447,7 @@ error_clear_array:
error_free: error_free:
free(impl); free(impl);
error_cleanup: error_cleanup:
if (properties) pw_properties_free(properties);
pw_properties_free(properties);
errno = -res; errno = -res;
return NULL; return NULL;
} }
@ -510,8 +509,7 @@ int pw_impl_client_register(struct pw_impl_client *client,
return 0; return 0;
error_existed: error_existed:
if (properties) pw_properties_free(properties);
pw_properties_free(properties);
return -EEXIST; return -EEXIST;
} }

View file

@ -463,8 +463,7 @@ struct pw_impl_core *pw_context_create_core(struct pw_context *context,
return this; return this;
error_exit: error_exit:
if (properties) pw_properties_free(properties);
pw_properties_free(properties);
free(this); free(this);
errno = -res; errno = -res;
return NULL; return NULL;
@ -652,8 +651,7 @@ error_existed:
res = -EEXIST; res = -EEXIST;
goto error_exit; goto error_exit;
error_exit: error_exit:
if (properties) pw_properties_free(properties);
pw_properties_free(properties);
return res; return res;
} }

View file

@ -185,8 +185,7 @@ struct pw_impl_device *pw_context_create_device(struct pw_context *context,
error_free: error_free:
free(impl); free(impl);
error_cleanup: error_cleanup:
if (properties) pw_properties_free(properties);
pw_properties_free(properties);
errno = -res; errno = -res;
return NULL; return NULL;
} }
@ -602,8 +601,7 @@ int pw_impl_device_register(struct pw_impl_device *device,
return 0; return 0;
error_existed: error_existed:
if (properties) pw_properties_free(properties);
pw_properties_free(properties);
return -EEXIST; return -EEXIST;
} }

View file

@ -73,8 +73,7 @@ struct pw_impl_factory *pw_context_create_factory(struct pw_context *context,
return this; return this;
error_exit: error_exit:
if (properties) pw_properties_free(properties);
pw_properties_free(properties);
errno = -res; errno = -res;
return NULL; return NULL;
} }
@ -218,8 +217,7 @@ int pw_impl_factory_register(struct pw_impl_factory *factory,
return 0; return 0;
error_existed: error_existed:
if (properties) pw_properties_free(properties);
pw_properties_free(properties);
return -EEXIST; return -EEXIST;
} }

View file

@ -1200,8 +1200,7 @@ error_no_io:
error_free: error_free:
free(impl); free(impl);
error_exit: error_exit:
if (properties) pw_properties_free(properties);
pw_properties_free(properties);
errno = -res; errno = -res;
return NULL; return NULL;
} }
@ -1278,8 +1277,7 @@ int pw_impl_link_register(struct pw_impl_link *link,
return 0; return 0;
error_existed: error_existed:
if (properties) pw_properties_free(properties);
pw_properties_free(properties);
return -EEXIST; return -EEXIST;
} }

View file

@ -291,8 +291,7 @@ error_free_filename:
if (filename) if (filename)
free(filename); free(filename);
error_cleanup: error_cleanup:
if (properties) pw_properties_free(properties);
pw_properties_free(properties);
errno = -res; errno = -res;
return NULL; return NULL;
} }

View file

@ -718,8 +718,7 @@ int pw_impl_node_register(struct pw_impl_node *this,
return 0; return 0;
error_existed: error_existed:
if (properties) pw_properties_free(properties);
pw_properties_free(properties);
return -EEXIST; return -EEXIST;
} }
@ -1235,8 +1234,7 @@ error_clean:
spa_system_close(this->context->data_system, this->source.fd); spa_system_close(this->context->data_system, this->source.fd);
free(impl); free(impl);
error_exit: error_exit:
if (properties) pw_properties_free(properties);
pw_properties_free(properties);
errno = -res; errno = -res;
return NULL; return NULL;
} }

View file

@ -186,8 +186,7 @@ void pw_mempool_destroy(struct pw_mempool *pool)
spa_hook_list_clean(&impl->listener_list); spa_hook_list_clean(&impl->listener_list);
pw_map_clear(&impl->map); pw_map_clear(&impl->map);
if (pool->props) pw_properties_free(pool->props);
pw_properties_free(pool->props);
free(impl); free(impl);
} }

View file

@ -377,7 +377,12 @@ int pw_properties_add_keys(struct pw_properties *props,
SPA_EXPORT SPA_EXPORT
void pw_properties_free(struct pw_properties *properties) void pw_properties_free(struct pw_properties *properties)
{ {
struct properties *impl = SPA_CONTAINER_OF(properties, struct properties, this); struct properties *impl;
if (properties == NULL)
return;
impl = SPA_CONTAINER_OF(properties, struct properties, this);
pw_properties_clear(properties); pw_properties_clear(properties);
pw_array_clear(&impl->items); pw_array_clear(&impl->items);
free(impl); free(impl);

View file

@ -1304,12 +1304,10 @@ stream_new(struct pw_context *context, const char *name,
return impl; return impl;
error_properties: error_properties:
if (impl->port_props) pw_properties_free(impl->port_props);
pw_properties_free(impl->port_props);
free(impl); free(impl);
error_cleanup: error_cleanup:
if (props) pw_properties_free(props);
pw_properties_free(props);
errno = -res; errno = -res;
return NULL; return NULL;
} }
@ -1375,8 +1373,7 @@ pw_stream_new_simple(struct pw_loop *loop,
error_cleanup: error_cleanup:
if (context) if (context)
pw_context_destroy(context); pw_context_destroy(context);
if (props) pw_properties_free(props);
pw_properties_free(props);
errno = -res; errno = -res;
return NULL; return NULL;
} }
@ -1794,8 +1791,7 @@ error_proxy:
goto exit_cleanup; goto exit_cleanup;
exit_cleanup: exit_cleanup:
if (props) pw_properties_free(props);
pw_properties_free(props);
return res; return res;
} }

View file

@ -1753,8 +1753,7 @@ error_no_context:
error_no_props: error_no_props:
error_no_main_loop: error_no_main_loop:
error_bad_file: error_bad_file:
if (data.props) pw_properties_free(data.props);
pw_properties_free(data.props);
if (data.file) if (data.file)
sf_close(data.file); sf_close(data.file);
if (data.midi.file) if (data.midi.file)

View file

@ -356,8 +356,7 @@ static int destroy_global(void *obj, void *data)
return 0; return 0;
pw_map_remove(&global->rd->globals, global->id); pw_map_remove(&global->rd->globals, global->id);
if (global->properties) pw_properties_free(global->properties);
pw_properties_free(global->properties);
free(global->type); free(global->type);
free(global); free(global);
return 0; return 0;
@ -931,8 +930,7 @@ static const struct pw_device_events device_events = {
static void session_info_free(struct pw_session_info *info) static void session_info_free(struct pw_session_info *info)
{ {
free(info->params); free(info->params);
if (info->props) pw_properties_free ((struct pw_properties *)info->props);
pw_properties_free ((struct pw_properties *)info->props);
free(info); free(info);
} }
@ -955,8 +953,7 @@ static void session_event_info(void *object,
info->n_params * sizeof(struct spa_param_info)); info->n_params * sizeof(struct spa_param_info));
} }
if (update->change_mask & PW_ENDPOINT_CHANGE_MASK_PROPS) { if (update->change_mask & PW_ENDPOINT_CHANGE_MASK_PROPS) {
if (info->props) pw_properties_free ((struct pw_properties *)info->props);
pw_properties_free ((struct pw_properties *)info->props);
info->props = info->props =
(struct spa_dict *) pw_properties_new_dict (update->props); (struct spa_dict *) pw_properties_new_dict (update->props);
} }
@ -980,8 +977,7 @@ static void endpoint_info_free(struct pw_endpoint_info *info)
free(info->name); free(info->name);
free(info->media_class); free(info->media_class);
free(info->params); free(info->params);
if (info->props) pw_properties_free ((struct pw_properties *)info->props);
pw_properties_free ((struct pw_properties *)info->props);
free(info); free(info);
} }
@ -1012,8 +1008,7 @@ static void endpoint_event_info(void *object,
info->n_params * sizeof(struct spa_param_info)); info->n_params * sizeof(struct spa_param_info));
} }
if (update->change_mask & PW_ENDPOINT_CHANGE_MASK_PROPS) { if (update->change_mask & PW_ENDPOINT_CHANGE_MASK_PROPS) {
if (info->props) pw_properties_free ((struct pw_properties *)info->props);
pw_properties_free ((struct pw_properties *)info->props);
info->props = info->props =
(struct spa_dict *) pw_properties_new_dict (update->props); (struct spa_dict *) pw_properties_new_dict (update->props);
} }
@ -1036,8 +1031,7 @@ static void endpoint_stream_info_free(struct pw_endpoint_stream_info *info)
{ {
free(info->name); free(info->name);
free(info->params); free(info->params);
if (info->props) pw_properties_free ((struct pw_properties *)info->props);
pw_properties_free ((struct pw_properties *)info->props);
free(info); free(info);
} }
@ -1062,8 +1056,7 @@ static void endpoint_stream_event_info(void *object,
info->n_params * sizeof(struct spa_param_info)); info->n_params * sizeof(struct spa_param_info));
} }
if (update->change_mask & PW_ENDPOINT_STREAM_CHANGE_MASK_PROPS) { if (update->change_mask & PW_ENDPOINT_STREAM_CHANGE_MASK_PROPS) {
if (info->props) pw_properties_free ((struct pw_properties *)info->props);
pw_properties_free ((struct pw_properties *)info->props);
info->props = info->props =
(struct spa_dict *) pw_properties_new_dict (update->props); (struct spa_dict *) pw_properties_new_dict (update->props);
} }
@ -1295,8 +1288,7 @@ static bool do_create_device(struct data *data, const char *cmd, char *args, cha
props ? &props->dict : NULL, props ? &props->dict : NULL,
sizeof(struct proxy_data)); sizeof(struct proxy_data));
if (props) pw_properties_free(props);
pw_properties_free(props);
pd = pw_proxy_get_user_data(proxy); pd = pw_proxy_get_user_data(proxy);
pd->rd = rd; pd->rd = rd;
@ -1335,8 +1327,7 @@ static bool do_create_node(struct data *data, const char *cmd, char *args, char
props ? &props->dict : NULL, props ? &props->dict : NULL,
sizeof(struct proxy_data)); sizeof(struct proxy_data));
if (props) pw_properties_free(props);
pw_properties_free(props);
pd = pw_proxy_get_user_data(proxy); pd = pw_proxy_get_user_data(proxy);
pd->rd = rd; pd->rd = rd;
@ -1407,8 +1398,7 @@ static bool do_create_link(struct data *data, const char *cmd, char *args, char
props ? &props->dict : NULL, props ? &props->dict : NULL,
sizeof(struct proxy_data)); sizeof(struct proxy_data));
if (props) pw_properties_free(props);
pw_properties_free(props);
pd = pw_proxy_get_user_data(proxy); pd = pw_proxy_get_user_data(proxy);
pd->rd = rd; pd->rd = rd;

View file

@ -609,8 +609,7 @@ static void removed_proxy(void *user_data)
static void destroy_proxy(void *user_data) static void destroy_proxy(void *user_data)
{ {
struct global *g = user_data; struct global *g = user_data;
if (g->props) pw_properties_free(g->props);
pw_properties_free(g->props);
if (g->info) if (g->info)
g->info_destroy(g->info); g->info_destroy(g->info);
} }

View file

@ -198,8 +198,7 @@ static void object_destroy(struct object *o)
spa_list_remove(&o->link); spa_list_remove(&o->link);
if (o->proxy) if (o->proxy)
pw_proxy_destroy(o->proxy); pw_proxy_destroy(o->proxy);
if (o->props) pw_properties_free(o->props);
pw_properties_free(o->props);
clear_params(&o->param_list, SPA_ID_INVALID); clear_params(&o->param_list, SPA_ID_INVALID);
clear_params(&o->pending_list, SPA_ID_INVALID); clear_params(&o->pending_list, SPA_ID_INVALID);
free(o->type); free(o->type);
@ -1290,8 +1289,7 @@ static void registry_event_global(void *data, uint32_t id,
bind_failed: bind_failed:
pw_log_error("can't bind object for %u %s/%d: %m", id, type, version); pw_log_error("can't bind object for %u %s/%d: %m", id, type, version);
if (o->props) pw_properties_free(o->props);
pw_properties_free(o->props);
free(o); free(o);
return; return;
} }

View file

@ -251,10 +251,8 @@ exit:
pw_context_destroy(data.context); pw_context_destroy(data.context);
if (data.loop) if (data.loop)
pw_main_loop_destroy(data.loop); pw_main_loop_destroy(data.loop);
if (data.capture_props) pw_properties_free(data.capture_props);
pw_properties_free(data.capture_props); pw_properties_free(data.playback_props);
if (data.playback_props)
pw_properties_free(data.playback_props);
pw_deinit(); pw_deinit();
return res; return res;