# HG changeset patch # User Matti Hamalainen # Date 1675250246 -7200 # Node ID 3f84521fdd31fcb9abfbb67398bcd91bbf2b5a8a # Parent d91d1174cfd813763b00a5223eb9472dde0930f8 Urgh. Fix previous commit. diff -r d91d1174cfd8 -r 3f84521fdd31 th_datastruct.c --- a/th_datastruct.c Wed Feb 01 13:02:35 2023 +0200 +++ b/th_datastruct.c Wed Feb 01 13:17:26 2023 +0200 @@ -224,19 +224,31 @@ void th_llist_reverse(th_llist_t **list) { - th_llist_t *curr = *list, *prev = NULL; + th_llist_t + *f_curr = *list, *f_prev = NULL, + *b_curr = *list, *b_prev = NULL; - while (curr != NULL) + if (b_curr != NULL) + b_prev = b_curr->prev; + + while (f_curr != NULL) { - th_llist_t *next = curr->next; - curr->next = prev; - prev = curr; - curr = next; - if (curr != NULL) - curr->prev = prev; + th_llist_t + *f_next = f_curr->next, + *b_next = b_curr->prev; + + f_curr->next = f_prev; + f_prev = f_curr; + f_curr = f_next; + + b_curr->prev = b_prev; + b_prev = b_curr; + b_curr = b_next; } - *list = prev; + *list = f_prev; + if (b_curr != NULL) + b_curr->prev = b_prev; }