Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Ethereal-dev: Re: [Ethereal-dev] patch to pcap-util.c

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Nathan Jennings <njen@xxxxxxxxxxxxx>
Date: Mon, 07 Jul 2003 22:22:38 -0400
Guy Harris wrote:

Yes, but...

..."g_list_remove_link()" returns the new start of the GList, without
the element, and the loop was doing

        while (if_list != NULL) {
                g_free(if_list->data);
                if_list = g_list_remove_link(if_list, if_list);
        }

which amounts to

	while (there's anything in the list) {
		g_free(the data for the first element in the loop);
		remove that element and set the list to what remains in
		    the list - *not* to the remaining element;
	}

so, unless either

	1) the documentation for "g_list_remove_link()" is incorrect;

	2) "Returns: the new start of the GList, without the element."
	   doesn't mean what it sounds to me as if it should mean;

	3) the implementation is buggy;

the loop *will* traverse all elements in the list, as it's not using the
prev or next links.


Oh... my goodness. My mistake.  :o(  Sorry for the extra noise.

"if_list" was being set to NULL after the first pass through the loop by g_list_remove_link(). Which leads me to believe I ran into #3, "the implementation is buggy." I got somewhat of a bad feeling when I found that g_list_length() didn't return the correct number of elements when GList wasn't at the first element (list head).

What 1.2 glib version do you recommend I use for development/testing for any patches I submit? I'm currently using "glib-1.2.10_7" which appears to be the latest for 1.2 (ftp://ftp.gtk.org/pub/gtk/v1.2/).

Thanks for helping me figure this out,  -Nathan