diff src/audacious/eventqueue.c @ 4581:cf6711eeb12f

implement event_queue_with_data_free()
author Tomasz Mon <desowin@gmail.com>
date Wed, 21 May 2008 18:40:05 +0200
parents e71fe9091fc9
children d9b2fe7a2d04
line wrap: on
line diff
--- a/src/audacious/eventqueue.c	Wed May 21 17:19:17 2008 +0200
+++ b/src/audacious/eventqueue.c	Wed May 21 18:40:05 2008 +0200
@@ -27,6 +27,9 @@
     hook_call(hq->name, hq->user_data);
 
     g_free(hq->name);
+    if (hq->free_data && hq->user_data)
+        g_free(hq->user_data);
+
     g_slice_free(HookCallQueue, hq);
 
     return FALSE;
@@ -42,6 +45,7 @@
     hq = g_slice_new0(HookCallQueue);
     hq->name = g_strdup(name);
     hq->user_data = user_data;
+    hq->free_data = FALSE;
 
     g_idle_add_full(G_PRIORITY_HIGH_IDLE, eventqueue_handle, hq, NULL);
 }
@@ -56,6 +60,22 @@
     hq = g_slice_new0(HookCallQueue);
     hq->name = g_strdup(name);
     hq->user_data = user_data;
+    hq->free_data = FALSE;
 
     g_timeout_add(time, eventqueue_handle, hq);
 }
+
+void event_queue_with_data_free(const gchar *name, gpointer user_data)
+{
+    HookCallQueue *hq;
+
+    g_return_if_fail(name != NULL);
+    g_return_if_fail(user_data != NULL);
+
+    hq = g_slice_new0(HookCallQueue);
+    hq->name = g_strdup(name);
+    hq->user_data = user_data;
+    hq->free_data = TRUE;
+
+    g_idle_add_full(G_PRIORITY_HIGH_IDLE, eventqueue_handle, hq, NULL);
+}
\ No newline at end of file