behavior of g_list_insert_sorted()



The way g_list_insert_sorted() interprets the results of the compare
function seem non-intuitive to me.  From looking at glist.c it
appears that if the compare function returns 0, the data is not
inserted into the list at all.  "Standard" compare function
behavior (ie, those used for qsort and bsearch) is to return 0
if the elements are equal.

This is either a bug in g_list_insert_sorted(), or there is an
unstated "if the element is already in the list it won't be added"
behavior.

Any thoughts on this?  (I notice that g_list_insert_sorted() isn't
used anywhere in gtk, gimp, or gnome, so I guess nobody has run
across this before).

-Marc



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