Re: number list elements problem



Hi,

francex tiscali it writes:

> g_slist_remove_link (list, g_slist_nth (list, position));

You _always_ need to assign the returned list argument to your list
pointer or your code will break if the head of the list is modified.
Try to change that line to

  list = g_slist_remove_link (list, g_slist_nth (list, position));

BTW, you are using the list in a very inefficient way here. In order
for the node to be removed the list is traversed twice. This should be
avoided if you intent to put a lot of nodes into your list.


Sven



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]