Mercurial > hg > th-libs
changeset 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 |
files | th_datastruct.c |
diffstat | 1 files changed, 21 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- 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; }