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