comparison th_datastruct.c @ 755:3f84521fdd31

Urgh. Fix previous commit.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 01 Feb 2023 13:17:26 +0200
parents d91d1174cfd8
children 4bd82aca5e98
comparison
equal deleted inserted replaced
754:d91d1174cfd8 755:3f84521fdd31
222 } 222 }
223 223
224 224
225 void th_llist_reverse(th_llist_t **list) 225 void th_llist_reverse(th_llist_t **list)
226 { 226 {
227 th_llist_t *curr = *list, *prev = NULL; 227 th_llist_t
228 228 *f_curr = *list, *f_prev = NULL,
229 while (curr != NULL) 229 *b_curr = *list, *b_prev = NULL;
230 { 230
231 th_llist_t *next = curr->next; 231 if (b_curr != NULL)
232 curr->next = prev; 232 b_prev = b_curr->prev;
233 prev = curr; 233
234 curr = next; 234 while (f_curr != NULL)
235 if (curr != NULL) 235 {
236 curr->prev = prev; 236 th_llist_t
237 } 237 *f_next = f_curr->next,
238 238 *b_next = b_curr->prev;
239 *list = prev; 239
240 f_curr->next = f_prev;
241 f_prev = f_curr;
242 f_curr = f_next;
243
244 b_curr->prev = b_prev;
245 b_prev = b_curr;
246 b_curr = b_next;
247 }
248
249 *list = f_prev;
250 if (b_curr != NULL)
251 b_curr->prev = b_prev;
240 } 252 }
241 253
242 254
243 void th_llist_foreach(th_llist_t *list, void (*func)(th_llist_t *node, void *userdata), void *data) 255 void th_llist_foreach(th_llist_t *list, void (*func)(th_llist_t *node, void *userdata), void *data)
244 { 256 {