# HG changeset patch # User tuomov # Date 1069103065 -3600 # Node ID af2c6d224f9dc50b38a04726b4ba37afb0f1b98e # Parent d32ef6ce17a4009beaebdba895bcbec8cb8ea968 trunk: changeset 60 Check that PREV!=NULL when unlinking item from a list. (PREV must point to something if on list.) diff -r d32ef6ce17a4 -r af2c6d224f9d include/libtu/dlist.h --- 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 */