I have an application I am writing here using glib 2.2.0. In this application, I create a GList. I then add a single item to the list and then remove it. However, after removing it, the GList->next pointer seems to get pointed to an empty list element as can been seen with this gdb analysis: Breakpoint 1, freeProgram (data=0x8068658, userdata=0x0) at schedule.c:174 174 g_list_remove(Programs, program); (gdb) print Programs $1 = (struct _GList *) 0x8060428 (gdb) print *Programs $2 = {data = 0x8068658, next = 0x0, prev = 0x0} (gdb) print program $3 = (struct program *) 0x8068658 (gdb) next 175 g_free(program); (gdb) print *Programs $4 = {data = 0x0, next = 0x8060434, prev = 0x0} The program is interrupted by gdb just prior to executing "g_list_remove(Programs, program)". As you can see, at $1, Programs is shown to be a GList*. At $2, it is shown to have a single element, pointing to 0x8068658. At $3, we verify that "program" is where Programs->data points to. Then I execute the "g_list_remove(Programs, program)" to remove the (only) data item from the list. Then I examine the list again at $4, and it shows to have freed the "program" element, but has added a "next" element which looks like: (gdb) print *Programs->next $6 = {data = 0x0, next = 0x0, prev = 0x0} Is this the way g_list_remove is supposed to work? It seems wierd/silly that there should be a next element when the current one (data) is NULL. Or maybe I am not quite understanding GLists. b. -- Brian J. Murrell
Attachment:
pgp44kn_SufEC.pgp
Description: PGP signature