Re: G_LIST_REMOVE not working... at least not for me :-)
- From: Havoc Pennington <hp redhat com>
- To: Mike Dailey <daileyml yahoo com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: G_LIST_REMOVE not working... at least not for me :-)
- Date: Sat, 16 Nov 2002 19:41:02 -0500
On Sat, Nov 16, 2002 at 03:50:05PM -0800, Mike Dailey wrote:
mainConnMgmtComboList = g_list_remove
(mainConnMgmtComboList,
g_strdup(FMC->appCURMGMTHOST.c_str()));
C doesn't work this way; it doesn't know what the void* in the
GSList points to. You have to remove the string using exactly the
same pointer used to add the string.
GList*
remove_string_by_value (GList *list, const char *str)
{
GList *iter;
iter = list;
while (iter != NULL)
{
const char *s = iter->data;
if (strcmp (s, str) == 0)
return g_list_remove (list, iter->data);
iter = iter->next;
}
return list;
}
You can make it more efficient by unlinking the list node "iter" when
the string matches, instead of using g_list_remove which scans from
the front of the list, but it's somewhat more tricky.
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]