After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 653935 - g_slist_free_full/g_list_free_full iterates twice in the list
g_slist_free_full/g_list_free_full iterates twice in the list
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2011-07-04 10:53 UTC by Luiz Augusto von Dentz
Modified: 2011-07-11 00:44 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Luiz Augusto von Dentz 2011-07-04 10:53:06 UTC
The following code could be used instead:

  while (list)
    {
      GSList *next = list->next;
      (*free_func) (list->data);
      g_slist_free_1(list);
      list = next;
    }
Comment 1 Luiz Augusto von Dentz 2011-07-04 13:28:14 UTC
It seems there are some performance impact by using my code when using threads (g_thread_init()) since for each item it will cause g_mutex_lock() followed by g_mutex_unlock().


For non-threaded applications my version could probably be useful since it does not have this side effect.