glib-local: ad call for g_list_remove

Without it we can't build with older versions of glib2

Also fixed up a misuse of the g_list_remove function

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
This commit is contained in:
Neil Horman 2012-08-31 13:12:35 -04:00
parent 07d79648c1
commit 11277c20cf
3 changed files with 38 additions and 2 deletions

View File

@ -353,12 +353,12 @@ void rebuild_irq_db(void)
while(gentry) {
ninfo = gentry->data;
iinfo = get_irq_info(ninfo->irq);
new_irq_list = g_list_remove(gentry, ninfo);
new_irq_list = g_list_remove(new_irq_list, ninfo);
if (!iinfo) {
if (debug_mode)
printf("Adding untracked IRQ %d to database\n", ninfo->irq);
interrupts_db = g_list_append(interrupts_db, ninfo);
} else
} else
free(ninfo);
gentry = g_list_first(new_irq_list);

View File

@ -379,3 +379,37 @@ g_list_find_custom (GList *list,
return NULL;
}
/**
* g_list_remove:
* @list: a #GList
* @data: the data of the element to remove
*
* Removes an element from a #GList.
* If two elements contain the same data, only the first is removed.
* If none of the elements contain the data, the #GList is unchanged.
*
* Returns: the new start of the #GList
*/
GList*
g_list_remove (GList *list,
gconstpointer data)
{
GList *tmp;
tmp = list;
while (tmp)
{
if (tmp->data != data)
tmp = tmp->next;
else
{
list = _g_list_remove_link(list, tmp);
g_list_free(tmp);
break;
}
}
return list;
}

View File

@ -43,6 +43,8 @@ void g_list_free_full (GList *list,
GList* g_list_find_custom (GList *list,
gconstpointer data,
GCompareFunc func);
GList* g_list_remove (GList *list,
gconstpointer data);
#define g_list_previous(list) ((list) ? (((GList *)(list))->prev) : NULL)
#define g_list_next(list) ((list) ? (((GList *)(list))->next) : NULL)