# HG changeset patch # User Mike Becker # Date 1326633625 -3600 # Node ID ccc294fafb9b82fcddc62c40abed56cce7466e05 # Parent 76cdd8209f1f2853b2e9187a8cd276c04cb3dab0 added ucx_list_remove diff -r 76cdd8209f1f -r ccc294fafb9b ucx/list.c --- a/ucx/list.c Sun Jan 15 14:12:34 2012 +0100 +++ b/ucx/list.c Sun Jan 15 14:20:25 2012 +0100 @@ -117,3 +117,22 @@ e = n; } } + +/* list specific functions */ +UcxList *ucx_list_remove(UcxList *l, UcxList *e) { + if (e == l) { + l = e->next; + free(e); + } else { + UcxList *f = l; + while (f->next != NULL && f->next != e) { + f = f->next; + } + /* perform remove iff this element is found in this list */ + if (f->next == e) { + f->next = e->next; + free(e); + } + } + return l; +} \ No newline at end of file diff -r 76cdd8209f1f -r ccc294fafb9b ucx/list.h --- a/ucx/list.h Sun Jan 15 14:12:34 2012 +0100 +++ b/ucx/list.h Sun Jan 15 14:20:25 2012 +0100 @@ -30,6 +30,8 @@ size_t ucx_list_size(UcxList *l); void ucx_list_foreach(UcxList *l, ucx_callback fnc, void *data); +/* list specific functions */ +UcxList *ucx_list_remove(UcxList *l, UcxList *e); #ifdef __cplusplus }