ucx/list.c

changeset 29
c96169444d88
parent 0
1f419bd32da1
child 124
80609f9675f1
equal deleted inserted replaced
28:794a5c91c479 29:c96169444d88
302 UcxList *ucx_list_remove(UcxList *l, UcxList *e) { 302 UcxList *ucx_list_remove(UcxList *l, UcxList *e) {
303 return ucx_list_remove_a(ucx_default_allocator(), l, e); 303 return ucx_list_remove_a(ucx_default_allocator(), l, e);
304 } 304 }
305 305
306 UcxList *ucx_list_remove_a(UcxAllocator *alloc, UcxList *l, UcxList *e) { 306 UcxList *ucx_list_remove_a(UcxAllocator *alloc, UcxList *l, UcxList *e) {
307 if (e->prev == NULL) { 307 if (l == e) {
308 if(e->next != NULL) { 308 l = e->next;
309 e->next->prev = NULL; 309 }
310 l = e->next; 310
311 } else { 311 if (e->next) {
312 l = NULL; 312 e->next->prev = e->prev;
313 } 313 }
314 314
315 } else { 315 if (e->prev) {
316 e->prev->next = e->next; 316 e->prev->next = e->next;
317 e->next->prev = e->prev; 317 }
318 } 318
319 alloc->free(alloc->pool, e); 319 alloc->free(alloc->pool, e);
320 return l; 320 return l;
321 } 321 }

mercurial