104 nl->prev = NULL; |
105 nl->prev = NULL; |
105 return nl; |
106 return nl; |
106 } |
107 } |
107 } |
108 } |
108 |
109 |
109 UcxList *ucx_list_append_once(UcxList *l, void *data, |
|
110 cmp_func cmpfnc, void *cmpdata) { |
|
111 return ucx_list_append_once_a(ucx_default_allocator(), l, |
|
112 data, cmpfnc, cmpdata); |
|
113 } |
|
114 |
|
115 UcxList *ucx_list_append_once_a(UcxAllocator *alloc, UcxList *l, void *data, |
|
116 cmp_func cmpfnc, void *cmpdata) { |
|
117 |
|
118 UcxList *last = NULL; |
|
119 { |
|
120 UcxList *e = l; |
|
121 while (e) { |
|
122 if (cmpfnc(e->data, data, cmpdata) == 0) { |
|
123 return l; |
|
124 } |
|
125 last = e; |
|
126 e = e->next; |
|
127 } |
|
128 } |
|
129 |
|
130 UcxList *nl = ucx_list_append_a(alloc, NULL, data); |
|
131 if (!nl) { |
|
132 return NULL; |
|
133 } |
|
134 |
|
135 if (last == NULL) { |
|
136 return nl; |
|
137 } else { |
|
138 nl->prev = last; |
|
139 last->next = nl; |
|
140 return l; |
|
141 } |
|
142 } |
|
143 |
|
144 UcxList *ucx_list_prepend(UcxList *l, void *data) { |
110 UcxList *ucx_list_prepend(UcxList *l, void *data) { |
145 return ucx_list_prepend_a(ucx_default_allocator(), l, data); |
111 return ucx_list_prepend_a(ucx_default_allocator(), l, data); |
146 } |
112 } |
147 |
113 |
148 UcxList *ucx_list_prepend_a(UcxAllocator *alloc, UcxList *l, void *data) { |
114 UcxList *ucx_list_prepend_a(UcxAllocator *alloc, UcxList *l, void *data) { |