trunk: changeset 60

Mon, 17 Nov 2003 22:04:25 +0100

author
tuomov
date
Mon, 17 Nov 2003 22:04:25 +0100
changeset 56
af2c6d224f9d
parent 55
d32ef6ce17a4
child 57
de75d868bc0b

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 */

mercurial