Skip to content
Snippets Groups Projects
Commit 0b3433d7 authored by George Kiagiadakis's avatar George Kiagiadakis
Browse files

modules: fix some ref counting and memory {de-,}allocation issues

parent ab73fd6e
No related branches found
No related tags found
No related merge requests found
...@@ -55,16 +55,10 @@ endpoint_info_destroy(gpointer p) ...@@ -55,16 +55,10 @@ endpoint_info_destroy(gpointer p)
struct endpoint_info *ei = p; struct endpoint_info *ei = p;
/* Free the name */ /* Free the name */
if (ei->name) { g_free (ei->name);
g_free (ei->name);
ei->name = NULL;
}
/* Free the media class */ /* Free the media class */
if (ei->media_class) { g_free (ei->media_class);
g_free (ei->media_class);
ei->media_class = NULL;
}
/* Clean up */ /* Clean up */
g_slice_free (struct endpoint_info, p); g_slice_free (struct endpoint_info, p);
...@@ -76,10 +70,7 @@ proxy_info_destroy(gpointer p) ...@@ -76,10 +70,7 @@ proxy_info_destroy(gpointer p)
struct proxy_info *pi = p; struct proxy_info *pi = p;
/* Unref the proxy port */ /* Unref the proxy port */
if (pi->proxy_port) { g_clear_object (&pi->proxy_port);
g_object_unref (pi->proxy_port);
pi->proxy_port = NULL;
}
/* Clean up */ /* Clean up */
g_slice_free (struct proxy_info, p); g_slice_free (struct proxy_info, p);
...@@ -122,8 +113,7 @@ proxy_node_created(GObject *initable, GAsyncResult *res, gpointer d) ...@@ -122,8 +113,7 @@ proxy_node_created(GObject *initable, GAsyncResult *res, gpointer d)
g_variant_builder_add (&b, "{sv}", g_variant_builder_add (&b, "{sv}",
"proxy-node", g_variant_new_uint64 ((guint64) proxy_node)); "proxy-node", g_variant_new_uint64 ((guint64) proxy_node));
g_variant_builder_add (&b, "{sv}", g_variant_builder_add (&b, "{sv}",
"proxy-port", g_variant_new_uint64 ((guint64) "proxy-port", g_variant_new_uint64 ((guint64) pi->proxy_port));
g_object_ref(pi->proxy_port)));
endpoint_props = g_variant_builder_end (&b); endpoint_props = g_variant_builder_end (&b);
/* Create the endpoint */ /* Create the endpoint */
...@@ -223,7 +213,7 @@ handle_node (struct module_data *data, uint32_t id, uint32_t parent_id, ...@@ -223,7 +213,7 @@ handle_node (struct module_data *data, uint32_t id, uint32_t parent_id,
SPA_PARAM_Profile, 0, param); SPA_PARAM_Profile, 0, param);
/* Create the endpoint info */ /* Create the endpoint info */
ei = g_new0(struct endpoint_info, 1); ei = g_slice_new0 (struct endpoint_info);
ei->name = g_strdup(name); ei->name = g_strdup(name);
ei->media_class = g_strdup(media_class); ei->media_class = g_strdup(media_class);
ei->proxy = proxy; ei->proxy = proxy;
...@@ -252,7 +242,7 @@ handle_port(struct module_data *data, uint32_t id, uint32_t parent_id, ...@@ -252,7 +242,7 @@ handle_port(struct module_data *data, uint32_t id, uint32_t parent_id,
return; return;
/* Create the port info */ /* Create the port info */
pi = g_new0(struct proxy_info, 1); pi = g_slice_new0 (struct proxy_info);
pi->data = data; pi->data = data;
pi->node_id = parent_id; pi->node_id = parent_id;
pi->proxy_port = NULL; pi->proxy_port = NULL;
...@@ -309,10 +299,7 @@ module_destroy (gpointer d) ...@@ -309,10 +299,7 @@ module_destroy (gpointer d)
struct module_data *data = d; struct module_data *data = d;
/* Destroy the hash table */ /* Destroy the hash table */
if (data->client_nodes_info) { g_hash_table_unref (data->client_nodes_info);
g_hash_table_destroy(data->client_nodes_info);
data->client_nodes_info = NULL;
}
/* Clean up */ /* Clean up */
g_slice_free (struct module_data, data); g_slice_free (struct module_data, data);
......
...@@ -49,16 +49,10 @@ endpoint_info_destroy(gpointer p) ...@@ -49,16 +49,10 @@ endpoint_info_destroy(gpointer p)
struct endpoint_info *ei = p; struct endpoint_info *ei = p;
/* Free the name */ /* Free the name */
if (ei->name) { g_free (ei->name);
g_free (ei->name);
ei->name = NULL;
}
/* Free the media class */ /* Free the media class */
if (ei->media_class) { g_free (ei->media_class);
g_free (ei->media_class);
ei->media_class = NULL;
}
/* Clean up */ /* Clean up */
g_slice_free (struct endpoint_info, p); g_slice_free (struct endpoint_info, p);
...@@ -70,10 +64,7 @@ proxy_info_destroy(gpointer p) ...@@ -70,10 +64,7 @@ proxy_info_destroy(gpointer p)
struct proxy_info *pi = p; struct proxy_info *pi = p;
/* Unref the proxy port */ /* Unref the proxy port */
if (pi->proxy_port) { g_clear_object (&pi->proxy_port);
g_object_unref (pi->proxy_port);
pi->proxy_port = NULL;
}
/* Clean up */ /* Clean up */
g_slice_free (struct proxy_info, p); g_slice_free (struct proxy_info, p);
...@@ -113,8 +104,7 @@ proxy_node_created(GObject *initable, GAsyncResult *res, gpointer data) ...@@ -113,8 +104,7 @@ proxy_node_created(GObject *initable, GAsyncResult *res, gpointer data)
g_variant_builder_add (&b, "{sv}", g_variant_builder_add (&b, "{sv}",
"proxy-node", g_variant_new_uint64 ((guint64) proxy_node)); "proxy-node", g_variant_new_uint64 ((guint64) proxy_node));
g_variant_builder_add (&b, "{sv}", g_variant_builder_add (&b, "{sv}",
"proxy-port", g_variant_new_uint64 ((guint64) "proxy-port", g_variant_new_uint64 ((guint64) pi->proxy_port));
g_object_ref(pi->proxy_port)));
endpoint_props = g_variant_builder_end (&b); endpoint_props = g_variant_builder_end (&b);
/* Create and register the endpoint */ /* Create and register the endpoint */
...@@ -181,7 +171,7 @@ handle_node(struct impl *impl, uint32_t id, uint32_t parent_id, ...@@ -181,7 +171,7 @@ handle_node(struct impl *impl, uint32_t id, uint32_t parent_id,
return; return;
/* Create the endpoint info */ /* Create the endpoint info */
ei = g_new0(struct endpoint_info, 1); ei = g_slice_new0 (struct endpoint_info);
ei->name = g_strdup(name); ei->name = g_strdup(name);
ei->media_class = g_strdup(media_class); ei->media_class = g_strdup(media_class);
...@@ -211,7 +201,7 @@ handle_port(struct impl *impl, uint32_t id, uint32_t parent_id, ...@@ -211,7 +201,7 @@ handle_port(struct impl *impl, uint32_t id, uint32_t parent_id,
return; return;
/* Create the port info */ /* Create the port info */
pi = g_new0(struct proxy_info, 1); pi = g_slice_new0 (struct proxy_info);
pi->impl = impl; pi->impl = impl;
pi->node_id = parent_id; pi->node_id = parent_id;
pi->proxy_port = NULL; pi->proxy_port = NULL;
...@@ -267,10 +257,7 @@ module_destroy (gpointer data) ...@@ -267,10 +257,7 @@ module_destroy (gpointer data)
struct impl *impl = data; struct impl *impl = data;
/* Destroy the hash table */ /* Destroy the hash table */
if (impl->alsa_nodes_info) { g_hash_table_unref (impl->alsa_nodes_info);
g_hash_table_destroy(impl->alsa_nodes_info);
impl->alsa_nodes_info = NULL;
}
/* Clean up */ /* Clean up */
g_slice_free (struct impl, impl); g_slice_free (struct impl, impl);
......
...@@ -340,16 +340,10 @@ endpoint_finalize (GObject * object) ...@@ -340,16 +340,10 @@ endpoint_finalize (GObject * object)
WpPwAudioSoftdspEndpoint *self = WP_PW_AUDIO_SOFTDSP_ENDPOINT (object); WpPwAudioSoftdspEndpoint *self = WP_PW_AUDIO_SOFTDSP_ENDPOINT (object);
/* Unref the proxy node */ /* Unref the proxy node */
if (self->proxy_node) { g_clear_object (&self->proxy_node);
g_object_unref(self->proxy_node);
self->proxy_node = NULL;
}
/* Unref the proxy port */ /* Unref the proxy port */
if (self->proxy_port) { g_clear_object (&self->proxy_port);
g_object_unref(self->proxy_port);
self->proxy_port = NULL;
}
/* Clear the dsp info */ /* Clear the dsp info */
if (self->dsp_info) { if (self->dsp_info) {
...@@ -376,11 +370,11 @@ endpoint_set_property (GObject * object, guint property_id, ...@@ -376,11 +370,11 @@ endpoint_set_property (GObject * object, guint property_id,
switch (property_id) { switch (property_id) {
case PROP_NODE_PROXY: case PROP_NODE_PROXY:
g_clear_object(&self->proxy_node); g_clear_object(&self->proxy_node);
self->proxy_node = g_value_get_object(value); self->proxy_node = g_value_dup_object(value);
break; break;
case PROP_PORT_PROXY: case PROP_PORT_PROXY:
g_clear_object(&self->proxy_port); g_clear_object(&self->proxy_port);
self->proxy_port = g_value_get_object(value); self->proxy_port = g_value_dup_object(value);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
...@@ -572,7 +566,7 @@ static const struct pw_registry_proxy_events registry_events = { ...@@ -572,7 +566,7 @@ static const struct pw_registry_proxy_events registry_events = {
static gpointer static gpointer
endpoint_factory (WpFactory * factory, GType type, GVariant * properties) endpoint_factory (WpFactory * factory, GType type, GVariant * properties)
{ {
WpCore *wp_core = NULL; g_autoptr (WpCore) wp_core = NULL;
WpRemote *remote; WpRemote *remote;
struct pw_remote *pw_remote; struct pw_remote *pw_remote;
const gchar *name = NULL; const gchar *name = NULL;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment