aboutsummaryrefslogtreecommitdiffstats
path: root/common/strlist.c
diff options
context:
space:
mode:
authorNeal H. Walfield <[email protected]>2015-11-06 09:51:35 +0000
committerNeal H. Walfield <[email protected]>2015-11-06 10:03:50 +0000
commitf38bac8883ea2e9ed8e2836f97a953efb85e774c (patch)
treecb78fec9c6d071702932036904dd7fcca7328825 /common/strlist.c
parentcommon: Include required, but not included headers in t-support.h. (diff)
downloadgnupg-f38bac8883ea2e9ed8e2836f97a953efb85e774c.tar.gz
gnupg-f38bac8883ea2e9ed8e2836f97a953efb85e774c.zip
common: Add new function strlist_rev.
* common/strlist.c (strlist_rev): New function. * common/t-strlist.c: New file. * common/Makefile.am (common_sources): Add strlist.c and strlist.h. (module_tests): Add t-strlist. (t_strlist_LDADD): New variable. -- Signed-off-by: Neal H. Walfield <[email protected]>
Diffstat (limited to 'common/strlist.c')
-rw-r--r--common/strlist.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/common/strlist.c b/common/strlist.c
index 9bd6195f9..760a46040 100644
--- a/common/strlist.c
+++ b/common/strlist.c
@@ -231,3 +231,22 @@ strlist_length (strlist_t list)
return i;
}
+
+/* Reverse the list *LIST in place. */
+strlist_t
+strlist_rev (strlist_t *list)
+{
+ strlist_t l = *list;
+ strlist_t lrev = NULL;
+
+ while (l)
+ {
+ strlist_t tail = l->next;
+ l->next = lrev;
+ lrev = l;
+ l = tail;
+ }
+
+ *list = lrev;
+ return lrev;
+}