If you have in your code things like that:
copy = g_slist_copy (list); g_slist_foreach (copy, g_object_ref, NULL);
In GLib 2.34 (to be released soon) you can do:
copy = g_slist_copy_deep (list, g_object_ref, NULL);
Thus eliminating another loop in the list (one loop is done when copying the list).
In other words, there’s now a function to do a deep (full) copy of a GList and GSList. It accepts, besides the list to be cloned, a function as a second argument, and a user data as the third argument. That function will be called for each element in the list.
To free the new list, use g_list_free_full().
0sem comentários ainda