Hi,

I'm having a problem that may be the result of my inexperience with GLib or it 
could be an issue with Glib on Windows XP.

I'm having several problems. The first is with g_list_index always returning 0. 
Am I correct that g_list_index searches the entire list starting at 0 to find 
the requested "data" OR does g_list_index start at the current position to find 
the data? If it's the former then I'm having a problem, if it's the latter then 
I assume that I have to set the starting position myself before initiating 
g_list_index.

If I'm positioned at the last element in the list and do this:

g_list_index(x, "something")

it returns 0 even though "something" exists in the list. However, if I do this 
instead:

g_list_index(g_list_first(x, "something"), "something")

it works. In this case I'm obviously setting the position of the list to the 
correct position before requesting the index... which seems redundant to me. 
I'm confused.


The second issue is with g_list_nth_prev. The docs suggest that if I try to 
move beyond the beginning of the list, g_list_nth_prev will return NULL and the 
list will remain at the position prior to the invalid g_list_nth_prev. For 
example, if I have a list containing 10 elements and I'm positioned at the last 
element, if I do the following:

if (NULL == (x = g_list_nth_prev(x, 99)))
  print an error message...
else
  proceed...

the program crashes. But if I do this:

if (NULL == g_list_nth_prev(x, 99))
  print an error message...
else
  x = g_list_nth_prev(x, 9);

it works correctly. The question is... should it work in the first case? My 
understanding of the docs suggest it should.


The third issue relates to the second one. Any GList function that can 
potentially advance the list beyond its boundaries is open to the same issue 
above. So any of the following functions can end with the same potential 
results:

g_list_nth
g_list_nth_datag_list_next
g_list_previous

Maybe others as well.

That's about it. Thanks for any help you can offer.

Gary
_______________________________________________
gtk-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gtk-list

Reply via email to