ptrlist.c

changeset 111
7d1dccdd7215
parent 101
50525dab6c8e
equal deleted inserted replaced
110:13134ea30227 111:7d1dccdd7215
51 51
52 return node; 52 return node;
53 } 53 }
54 54
55 55
56 bool ptrlist_contains(PtrList *ptrlist, void *ptr)
57 {
58 return (ptrlist_find_node(ptrlist, ptr)!=NULL);
59 }
60
61
56 bool ptrlist_insert_last(PtrList **ptrlist, void *ptr) 62 bool ptrlist_insert_last(PtrList **ptrlist, void *ptr)
57 { 63 {
58 PtrList *node=mknode(ptr); 64 PtrList *node=mknode(ptr);
59 65
60 if(node==NULL) 66 if(node==NULL)
82 bool ptrlist_reinsert_last(PtrList **ptrlist, void *ptr) 88 bool ptrlist_reinsert_last(PtrList **ptrlist, void *ptr)
83 { 89 {
84 PtrList *node=ptrlist_find_node(*ptrlist, ptr); 90 PtrList *node=ptrlist_find_node(*ptrlist, ptr);
85 91
86 if(node==NULL) 92 if(node==NULL)
87 return FALSE; 93 return ptrlist_insert_last(ptrlist, ptr);
88 94
89 UNLINK_ITEM(*ptrlist, node, next, prev); 95 UNLINK_ITEM(*ptrlist, node, next, prev);
90 LINK_ITEM_LAST(*ptrlist, node, next, prev); 96 LINK_ITEM_LAST(*ptrlist, node, next, prev);
91 97
92 return TRUE; 98 return TRUE;
96 bool ptrlist_reinsert_first(PtrList **ptrlist, void *ptr) 102 bool ptrlist_reinsert_first(PtrList **ptrlist, void *ptr)
97 { 103 {
98 PtrList *node=ptrlist_find_node(*ptrlist, ptr); 104 PtrList *node=ptrlist_find_node(*ptrlist, ptr);
99 105
100 if(node==NULL) 106 if(node==NULL)
101 return FALSE; 107 return ptrlist_insert_first(ptrlist, ptr);
102 108
103 UNLINK_ITEM(*ptrlist, node, next, prev); 109 UNLINK_ITEM(*ptrlist, node, next, prev);
104 LINK_ITEM_FIRST(*ptrlist, node, next, prev); 110 LINK_ITEM_FIRST(*ptrlist, node, next, prev);
105 111
106 return TRUE; 112 return TRUE;

mercurial