Re: String equivalence in glib functions (such as g_slist_remove)



On Sat, Jul 28, 2007 at 07:51:42PM +0100, j t wrote:
> ...
> I assume that this is because the dynamically allocated strings aren't
> "the same" (i.e. they're at different places in memory). What do
> people generally do when their idea of equivalence isn't the same as
> "=="? Is there some way of getting glib's functions to use an
> "equivalence function" rather than the "hardcoded" "=="?

Use g_slist_find_custom() to find the item using an
arbitrary comparison function (in the described example you
can directly pass a string comparison function) and then
remove it.  Most GLib data structures offer this kind of
functionality.

Yeti

--
http://gwyddion.net/



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