diff options
author | Christophe Fergeau <cfergeau@redhat.com> | 2014-04-11 10:36:04 +0200 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2014-04-15 10:24:09 +0200 |
commit | 5a1c94f4ad263ec87d41ae89d597567ddf9bf3b7 (patch) | |
tree | 773905f2042e2a400b1741a11d8a72c1737367e2 | |
parent | 9dcdfebf4f6688d6710a00db033bb6803bbbb247 (diff) |
Add compat implementation of g_queue_free_full()
This was introduced in glib 2.32 and the webdav channel uses it.
-rw-r--r-- | gtk/glib-compat.c | 22 | ||||
-rw-r--r-- | gtk/glib-compat.h | 3 |
2 files changed, 25 insertions, 0 deletions
diff --git a/gtk/glib-compat.c b/gtk/glib-compat.c index f940e0a..9d1165e 100644 --- a/gtk/glib-compat.c +++ b/gtk/glib-compat.c @@ -100,6 +100,28 @@ g_slist_free_full (GSList *list, G_DEFINE_BOXED_TYPE (GMainContext, spice_main_context, g_main_context_ref, g_main_context_unref) #endif + +#if !GLIB_CHECK_VERSION(2,32,0) +/** + * g_queue_free_full: + * @queue: a pointer to a #GQueue + * @free_func: the function to be called to free each element's data + * + * Convenience method, which frees all the memory used by a #GQueue, + * and calls the specified destroy function on every element's data. + * + * Since: 2.32 + */ +void +g_queue_free_full (GQueue *queue, + GDestroyNotify free_func) +{ + g_queue_foreach (queue, (GFunc) free_func, NULL); + g_queue_free (queue); +} +#endif + + #if !GLIB_CHECK_VERSION(2,27,2) guint64 g_get_monotonic_time(void) { diff --git a/gtk/glib-compat.h b/gtk/glib-compat.h index 4acf401..45d961e 100644 --- a/gtk/glib-compat.h +++ b/gtk/glib-compat.h @@ -112,6 +112,9 @@ GType spice_main_context_get_type (void) G_GNUC_CONST; #if !GLIB_CHECK_VERSION(2,32,0) # define G_SIGNAL_DEPRECATED (1 << 9) +void +g_queue_free_full (GQueue *queue, + GDestroyNotify free_func); #endif #ifndef g_clear_pointer |