Mon, 17 Nov 2003 22:04:25 +0100
trunk: changeset 60
Check that PREV!=NULL when unlinking item from a list. (PREV must
point to something if on list.)
include/libtu/dlist.h | file | annotate | diff | comparison | revisions |
--- a/include/libtu/dlist.h Mon Nov 17 14:28:28 2003 +0100 +++ b/include/libtu/dlist.h Mon Nov 17 22:04:25 2003 +0100 @@ -56,19 +56,21 @@ (ITEM)->NEXT->PREV=ITEM; -#define UNLINK_ITEM(LIST, ITEM, NEXT, PREV) \ - if((ITEM)==(LIST)){ \ - (LIST)=(ITEM)->NEXT; \ - if((LIST)!=NULL) \ - (LIST)->PREV=(ITEM)->PREV; \ - }else if((ITEM)->NEXT==NULL){ \ - (ITEM)->PREV->NEXT=NULL; \ - (LIST)->PREV=(ITEM)->PREV; \ - }else{ \ - (ITEM)->PREV->NEXT=(ITEM)->NEXT; \ - (ITEM)->NEXT->PREV=(ITEM)->PREV; \ - } \ - (ITEM)->NEXT=NULL; \ +#define UNLINK_ITEM(LIST, ITEM, NEXT, PREV) \ + if((ITEM)->PREV!=NULL){ \ + if((ITEM)==(LIST)){ \ + (LIST)=(ITEM)->NEXT; \ + if((LIST)!=NULL) \ + (LIST)->PREV=(ITEM)->PREV; \ + }else if((ITEM)->NEXT==NULL){ \ + (ITEM)->PREV->NEXT=NULL; \ + (LIST)->PREV=(ITEM)->PREV; \ + }else{ \ + (ITEM)->PREV->NEXT=(ITEM)->NEXT; \ + (ITEM)->NEXT->PREV=(ITEM)->PREV; \ + } \ + } \ + (ITEM)->NEXT=NULL; \ (ITEM)->PREV=NULL; #endif /* LIBTU_DLIST_H */