aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-08-09 11:32:05 +0100
committerConor Curran <conor.curran@canonical.com>2011-08-09 11:32:05 +0100
commit014e2b2a3582f3e823e61e23d391c68b474e16b4 (patch)
tree04b7d03c6f219ddcf1234768d8d7e7d9cb48c58f
parent7ccf396039ca441059913c9caa407d4662ed7b19 (diff)
downloadayatana-indicator-session-014e2b2a3582f3e823e61e23d391c68b474e16b4.tar.gz
ayatana-indicator-session-014e2b2a3582f3e823e61e23d391c68b474e16b4.tar.bz2
ayatana-indicator-session-014e2b2a3582f3e823e61e23d391c68b474e16b4.zip
fixed memory leaks
-rw-r--r--src/udev-mgr.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/udev-mgr.c b/src/udev-mgr.c
index cbb7dcb..5ac286e 100644
--- a/src/udev-mgr.c
+++ b/src/udev-mgr.c
@@ -45,9 +45,14 @@ static void udev_mgr_handle_scsi_device (UdevMgr* self,
GUdevDevice* device,
UdevMgrDeviceAction action);
+static void udev_mgr_cleanup_lists(gpointer data, gpointer self);
+static void udev_mgr_cleanup_entries(gpointer data, gpointer self);
+
+
static void debug_device (UdevMgr* self,
GUdevDevice* device,
UdevMgrDeviceAction action);
+
struct _UdevMgr
{
@@ -80,11 +85,11 @@ udev_mgr_init (UdevMgr* self)
self->supported_usb_scanners = g_hash_table_new_full (g_str_hash,
g_str_equal,
g_free,
- (GDestroyNotify)g_list_free);
+ (GDestroyNotify)udev_mgr_cleanup_lists);
self->supported_scsi_scanners = g_hash_table_new_full (g_str_hash,
g_str_equal,
g_free,
- (GDestroyNotify)g_list_free);
+ (GDestroyNotify)udev_mgr_cleanup_lists);
self->scanners_present = g_hash_table_new_full (g_str_hash,
g_str_equal,
g_free,
@@ -104,6 +109,21 @@ udev_mgr_init (UdevMgr* self)
}
static void
+udev_mgr_cleanup_lists(gpointer data, gpointer self)
+{
+ GList* scanners = (GList*)data;
+ g_list_foreach (scanners, udev_mgr_cleanup_entries, NULL);
+ g_list_free(scanners);
+}
+
+static void
+udev_mgr_cleanup_entries(gpointer data, gpointer self)
+{
+ gchar* entry = (gchar*)data;
+ g_free(entry);
+}
+
+static void
udev_mgr_finalize (GObject *object)
{
UdevMgr* self = UDEV_MGR (object);
@@ -283,9 +303,8 @@ static void udev_mgr_handle_scsi_device (UdevMgr* self,
if (g_strcmp0 (type, "6") == 0){
gchar* random_scanner_name = g_strdup_printf("%p--scanner", self);
g_hash_table_insert (self->scanners_present,
- g_strdup(random_scanner_name),
+ random_scanner_name,
g_strdup("Scanner"));
- g_free (random_scanner_name);
udev_mgr_update_menuitems (self);
return;
}