added ucx_list_remove

Sun, 15 Jan 2012 14:20:25 +0100

author
Mike Becker <universe@uap-core.de>
date
Sun, 15 Jan 2012 14:20:25 +0100
changeset 23
ccc294fafb9b
parent 22
76cdd8209f1f
child 24
e04822101291

added ucx_list_remove

ucx/list.c file | annotate | diff | comparison | revisions
ucx/list.h file | annotate | diff | comparison | revisions
     1.1 --- a/ucx/list.c	Sun Jan 15 14:12:34 2012 +0100
     1.2 +++ b/ucx/list.c	Sun Jan 15 14:20:25 2012 +0100
     1.3 @@ -117,3 +117,22 @@
     1.4          e = n;
     1.5      }
     1.6  }
     1.7 +
     1.8 +/* list specific functions */
     1.9 +UcxList *ucx_list_remove(UcxList *l, UcxList *e) {
    1.10 +    if (e == l) {
    1.11 +        l = e->next;
    1.12 +        free(e);
    1.13 +    } else {
    1.14 +        UcxList *f = l;
    1.15 +        while (f->next != NULL && f->next != e) {
    1.16 +            f = f->next;
    1.17 +        }
    1.18 +        /* perform remove iff this element is found in this list */
    1.19 +        if (f->next == e) {
    1.20 +            f->next = e->next;
    1.21 +            free(e);
    1.22 +        }
    1.23 +    }
    1.24 +    return l;
    1.25 +}
    1.26 \ No newline at end of file
     2.1 --- a/ucx/list.h	Sun Jan 15 14:12:34 2012 +0100
     2.2 +++ b/ucx/list.h	Sun Jan 15 14:20:25 2012 +0100
     2.3 @@ -30,6 +30,8 @@
     2.4  size_t ucx_list_size(UcxList *l);
     2.5  void ucx_list_foreach(UcxList *l, ucx_callback fnc, void *data);
     2.6  
     2.7 +/* list specific functions */
     2.8 +UcxList *ucx_list_remove(UcxList *l, UcxList *e);
     2.9  
    2.10  #ifdef	__cplusplus
    2.11  }

mercurial