Ross, your examples are not as bad as something I found in some code I had to fix recently:
GList *list = e_vcard_get_attributes (evcard);
for (list = g_list_first (list);
list != NULL;
list = g_list_next (list))
{
/* Do something */
}
for (list = g_list_first (list);
list != NULL;
list = g_list_next (list))
{
/* Do something else */
g_object_unref (list->data);
}
g_free (g_list_first (list));
“Surprisingly” it was not working, but at least it was not leaking memory as the return value of e_vcard_get_attributes is not supposed to be freed 