Mercurial > hg > toybox
comparison lib/llist.c @ 1060:c2663b7eca78 draft
Adjust patch to use dlist_pop()
author | Rob Landley <rob@landley.net> |
---|---|
date | Mon, 09 Sep 2013 05:26:52 -0500 |
parents | ef72a16f4b3a |
children | 114ec0ab161c |
comparison
equal
deleted
inserted
replaced
1059:ef72a16f4b3a | 1060:c2663b7eca78 |
---|---|
35 | 35 |
36 void *dlist_pop(void *list) | 36 void *dlist_pop(void *list) |
37 { | 37 { |
38 struct double_list **pdlist = (struct double_list **)list, *dlist = *pdlist; | 38 struct double_list **pdlist = (struct double_list **)list, *dlist = *pdlist; |
39 | 39 |
40 dlist->next->prev = dlist->prev; | 40 if (dlist->next == dlist) *pdlist = 0; |
41 dlist->prev->next = *pdlist = dlist->next; | 41 else { |
42 dlist->next->prev = dlist->prev; | |
43 dlist->prev->next = *pdlist = dlist->next; | |
44 } | |
42 | 45 |
43 return dlist; | 46 return dlist; |
44 } | 47 } |
45 | 48 |
46 void dlist_add_nomalloc(struct double_list **list, struct double_list *new) | 49 void dlist_add_nomalloc(struct double_list **list, struct double_list *new) |