Use hash iterators

svn path=/trunk/; revision=6132
This commit is contained in:
Matthias Clasen 2007-12-15 04:39:26 +00:00
parent 1f7e7f84f4
commit 2f3aef1617
3 changed files with 16 additions and 26 deletions

View File

@ -1,3 +1,8 @@
2007-12-14 Matthias Clasen <mclasen@redhat.com>
* gcontenttype.c:
* gdesktopappinfo.c: Use hash table iterators.
2007-12-14 Alexander Larsson <alexl@redhat.com> 2007-12-14 Alexander Larsson <alexl@redhat.com>
* Makefile.am: * Makefile.am:

View File

@ -781,17 +781,6 @@ g_content_type_guess (const char *filename,
return mimetype; 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 static void
enumerate_mimetypes_subdir (const char *dir, enumerate_mimetypes_subdir (const char *dir,
const char *prefix, const char *prefix,
@ -859,6 +848,8 @@ g_content_types_get_registered (void)
{ {
const char * const* dirs; const char * const* dirs;
GHashTable *mimetypes; GHashTable *mimetypes;
GHashTableIter iter;
gpointer key;
int i; int i;
GList *l; GList *l;
@ -871,7 +862,10 @@ g_content_types_get_registered (void)
enumerate_mimetypes_dir (dirs[i], mimetypes); enumerate_mimetypes_dir (dirs[i], mimetypes);
l = NULL; 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); g_hash_table_destroy (mimetypes);
return l; return l;

View File

@ -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: * g_app_info_get_all:
@ -1675,6 +1664,8 @@ g_app_info_get_all (void)
{ {
const char * const *dirs; const char * const *dirs;
GHashTable *apps; GHashTable *apps;
GHashTableIter iter;
gpointer key;
int i; int i;
GList *infos; GList *infos;
@ -1689,9 +1680,9 @@ g_app_info_get_all (void)
infos = NULL; infos = NULL;
g_hash_table_foreach (apps, g_hash_table_iter_init (&iter, apps);
collect_apps, while (g_hash_table_iter_next (&iter, &key, NULL))
&infos); infos = g_list_prepend (infos, key);
g_hash_table_destroy (apps); g_hash_table_destroy (apps);