summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Ryan <mark.d.ryan@intel.com>2013-09-25 16:24:08 +0200
committerMark Ryan <mark.d.ryan@intel.com>2013-09-26 10:56:04 +0200
commit26af6087ef1c03781f2a7d0f9c1b079509198ca7 (patch)
treeffcf27552d5f2b095cb51ec12d3802300fc03e5f
parent951a45203d2e9bd26bdc5219ea6639f874991578 (diff)
downloaddleyna-renderer-26af6087ef1c03781f2a7d0f9c1b079509198ca7.tar.gz
[Memory Leak] Partial fix for bug 129
https://github.com/01org/dleyna-renderer/issues/129 This commit attempts to partially fix bug 129. It cannot be completely fixed at the moment due to a bug in GUPnP. https://bugzilla.gnome.org/show_bug.cgi?id=708751 At least we're freeing the list now, if not the strings that it contains. Also, to reduce the effect of the memory leak, this commit ensures that it only happens once per renderer rather than once each time we receive an event from a renderer. The assumption is that a device will not dynamically change the DLNA classes that it supports. Signed-off-by: Mark Ryan <mark.d.ryan@intel.com>
-rw-r--r--libdleyna/renderer/device.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/libdleyna/renderer/device.c b/libdleyna/renderer/device.c
index c51f865..7b3e8b2 100644
--- a/libdleyna/renderer/device.c
+++ b/libdleyna/renderer/device.c
@@ -1118,16 +1118,36 @@ static GVariant *prv_as_prop_from_list(GList *list)
return g_variant_ref_sink(g_variant_builder_end(&vb));
}
-static void prv_update_prop_dlna_device_classes(GUPnPDeviceInfo *proxy,
- GHashTable *props)
+static GVariant *prv_update_prop_dlna_device_classes(GUPnPDeviceInfo *proxy,
+ GHashTable *props)
{
- GList *dlna_classes =
+ GVariant *retval;
+ GList *dlna_classes;
+
+ retval = g_hash_table_lookup(props,
+ DLR_INTERFACE_PROP_DLNA_DEVICE_CLASSES);
+ if (retval)
+ goto on_exit;
+
+ dlna_classes =
gupnp_device_info_list_dlna_device_class_identifier(proxy);
- if (dlna_classes != NULL)
- g_hash_table_insert(props,
- DLR_INTERFACE_PROP_DLNA_DEVICE_CLASSES,
- prv_as_prop_from_list(dlna_classes));
+ if (!dlna_classes)
+ goto on_exit;
+
+ retval = prv_as_prop_from_list(dlna_classes);
+ g_hash_table_insert(props, DLR_INTERFACE_PROP_DLNA_DEVICE_CLASSES,
+ retval);
+
+ /* TODO: We should actually be calling g_list_free_full here but the
+ strings in dlna_classes are allocated by libxml and not glib. So
+ until this is fixed we're stuck with this. */
+
+ g_list_free(dlna_classes);
+
+on_exit:
+
+ return retval;
}
static void prv_add_actions(dlr_device_t *device,
@@ -1165,10 +1185,8 @@ static void prv_add_actions(dlr_device_t *device,
info = (GUPnPDeviceInfo *)dlr_device_get_context(device)->device_proxy;
- prv_update_prop_dlna_device_classes(info, device->props.device_props);
-
- val = g_hash_table_lookup(device->props.device_props,
- DLR_INTERFACE_PROP_DLNA_DEVICE_CLASSES);
+ val = prv_update_prop_dlna_device_classes(info,
+ device->props.device_props);
/* If this device is not dlna compatible, there is no need */
/* to check for “X_DLNA_SeekTime” */
@@ -2234,7 +2252,7 @@ static void prv_update_device_props(GUPnPDeviceInfo *proxy, GHashTable *props)
GVariant *val;
gchar *str;
- prv_update_prop_dlna_device_classes(proxy, props);
+ (void) prv_update_prop_dlna_device_classes(proxy, props);
val = g_variant_ref_sink(g_variant_new_string(
gupnp_device_info_get_device_type(proxy)));