From 0b3e9ebd7342170fefd27a2ab4b7e243d8a750a5 Mon Sep 17 00:00:00 2001 From: grunfink Date: Wed, 24 Jun 2026 11:39:39 +0200 Subject: Moved xs_list_reverse() to xs.h. --- xs_list_tools.h | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'xs_list_tools.h') diff --git a/xs_list_tools.h b/xs_list_tools.h index 33d4b87..f47d782 100644 --- a/xs_list_tools.h +++ b/xs_list_tools.h @@ -5,7 +5,6 @@ #define _XS_LIST_TOOLS_H xs_list *xs_list_insert_sorted(xs_list *list, const xs_val *nv); - xs_list *xs_list_reverse(const xs_list *l); xs_val **xs_list_to_array(const xs_list *l, int *len); int xs_list_sort_cmp(const void *p1, const void *p2); int xs_list_sort_inv_cmp(const void *p1, const void *p2); @@ -37,29 +36,6 @@ xs_list *xs_list_insert_sorted(xs_list *list, const xs_val *nv) } -xs_list *xs_list_reverse(const xs_list *l) -/* creates a new list as a reverse version of l */ -{ - xs_list *n = xs_dup(l); - const xs_val *v; - - /* move to one byte before the EOM */ - char *p = n + xs_size(n) - 1; - - xs_list_foreach(l, v) { - /* size of v, plus the LITEM */ - int z = xs_size(v) + 1; - - p -= z; - - /* copy v, including its LITEM */ - memcpy(p, v - 1, z); - } - - return n; -} - - xs_val **xs_list_to_array(const xs_list *l, int *len) /* converts a list to an array of values */ /* must be freed after use */ -- cgit