Mercurial > pidgin
diff src/prefs.c @ 14035:8bda65b88e49
[gaim-migrate @ 16638]
A bunch of small changes. Mostly remove "if not null" checks before
calling g_free, g_list_free, g_slist_free and g_strdup. Also use
g_list_foreach() to call g_free to free strings in an array. And
some whitespace changes here and there.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 05 Aug 2006 08:27:39 +0000 |
parents | 848c9685ecc7 |
children | 11394a70de37 |
line wrap: on
line diff
--- a/src/prefs.c Sat Aug 05 05:42:28 2006 +0000 +++ b/src/prefs.c Sat Aug 05 08:27:39 2006 +0000 @@ -463,7 +463,6 @@ { GString *name; struct gaim_pref *parent; - char *ret; if(!pref) return NULL; @@ -479,9 +478,7 @@ name = g_string_prepend(name, parent->name); } name = g_string_prepend_c(name, '/'); - ret = name->str; - g_string_free(name, FALSE); - return ret; + return g_string_free(name, FALSE); } static struct gaim_pref * @@ -514,10 +511,7 @@ break; case GAIM_PREF_STRING_LIST: { - GList *tmp; - for(tmp = pref->value.stringlist; tmp; tmp = tmp->next) - g_free(tmp->data); - + g_list_foreach(pref->value.stringlist, (GFunc)g_free, NULL); g_list_free(pref->value.stringlist); } break; case GAIM_PREF_NONE: @@ -794,15 +788,14 @@ return; } - for(tmp = pref->value.stringlist; tmp; tmp = tmp->next) - g_free(tmp->data); - + g_list_foreach(pref->value.stringlist, (GFunc)g_free, NULL); g_list_free(pref->value.stringlist); pref->value.stringlist = NULL; for(tmp = value; tmp; tmp = tmp->next) - pref->value.stringlist = g_list_append(pref->value.stringlist, + pref->value.stringlist = g_list_prepend(pref->value.stringlist, g_strdup(tmp->data)); + pref->value.stringlist = g_list_reverse(pref->value.stringlist); do_callbacks(name, pref); @@ -904,7 +897,8 @@ } for(tmp = pref->value.stringlist; tmp; tmp = tmp->next) - ret = g_list_append(ret, g_strdup(tmp->data)); + ret = g_list_prepend(ret, g_strdup(tmp->data)); + ret = g_list_reverse(ret); return ret; }