From: Matthias Clasen Date: Sat, 15 Dec 2007 04:39:26 +0000 (+0000) Subject: Use hash iterators X-Git-Tag: GLIB_2_15_1~129 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2f3aef1617b23b636033516361cc3fef06590460;p=platform%2Fupstream%2Fglib.git Use hash iterators svn path=/trunk/; revision=6132 --- diff --git a/gio/ChangeLog b/gio/ChangeLog index d3cba2e..33bd99a 100644 --- a/gio/ChangeLog +++ b/gio/ChangeLog @@ -1,3 +1,8 @@ +2007-12-14 Matthias Clasen + + * gcontenttype.c: + * gdesktopappinfo.c: Use hash table iterators. + 2007-12-14 Alexander Larsson * Makefile.am: diff --git a/gio/gcontenttype.c b/gio/gcontenttype.c index 1ef9d00..2404a7b 100644 --- a/gio/gcontenttype.c +++ b/gio/gcontenttype.c @@ -781,17 +781,6 @@ g_content_type_guess (const char *filename, return mimetype; } -static gboolean -foreach_mimetype (gpointer key, - gpointer value, - gpointer user_data) -{ - GList **l = user_data; - - *l = g_list_prepend (*l, (char *)key); - return TRUE; -} - static void enumerate_mimetypes_subdir (const char *dir, const char *prefix, @@ -859,6 +848,8 @@ g_content_types_get_registered (void) { const char * const* dirs; GHashTable *mimetypes; + GHashTableIter iter; + gpointer key; int i; GList *l; @@ -871,7 +862,10 @@ g_content_types_get_registered (void) enumerate_mimetypes_dir (dirs[i], mimetypes); l = NULL; - g_hash_table_foreach_steal (mimetypes, foreach_mimetype, &l); + g_hash_table_iter_init (&iter, mimetypes); + while (g_hash_table_iter_next (&iter, &key, NULL)) + l = g_list_prepend (l, key); + g_hash_table_destroy (mimetypes); return l; diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c index 8fc3a86..973148e 100644 --- a/gio/gdesktopappinfo.c +++ b/gio/gdesktopappinfo.c @@ -1651,17 +1651,6 @@ get_apps_from_dir (GHashTable *apps, } } -static void -collect_apps (gpointer key, - gpointer value, - gpointer user_data) -{ - GList **infos = user_data; - - if (value) - *infos = g_list_prepend (*infos, value); -} - /** * g_app_info_get_all: @@ -1675,6 +1664,8 @@ g_app_info_get_all (void) { const char * const *dirs; GHashTable *apps; + GHashTableIter iter; + gpointer key; int i; GList *infos; @@ -1689,9 +1680,9 @@ g_app_info_get_all (void) infos = NULL; - g_hash_table_foreach (apps, - collect_apps, - &infos); + g_hash_table_iter_init (&iter, apps); + while (g_hash_table_iter_next (&iter, &key, NULL)) + infos = g_list_prepend (infos, key); g_hash_table_destroy (apps);