aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-09-21 15:53:14 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-10-24 15:57:18 +0200
commit7f89eb3cfff465cf32d03a2ae6919252eae67e9b (patch)
treeed776d71106000dfa34ad4de3402fff6fea6c56a /include
parentc4ab32879df8b5e83b0ebd091ce2c750f53f5633 (diff)
libutil: add a string list helper to replace some of the adhoc ones
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include')
-rw-r--r--include/util/strlist.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/include/util/strlist.h b/include/util/strlist.h
new file mode 100644
index 0000000..ace4e20
--- /dev/null
+++ b/include/util/strlist.h
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: LGPL-3.0-or-later */
+/*
+ * strlist.h
+ *
+ * Copyright (C) 2023 David Oberhollenzer <goliath@infraroot.at>
+ */
+#ifndef UTIL_STRLIST_H
+#define UTIL_STRLIST_H
+
+#include "sqfs/predef.h"
+#include <string.h>
+
+typedef struct {
+ char **strings;
+ size_t count;
+ size_t capacity;
+} strlist_t;
+
+static SQFS_INLINE void strlist_init(strlist_t *list)
+{
+ memset(list, 0, sizeof(*list));
+}
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+SQFS_INTERNAL int strlist_init_copy(strlist_t *dst, const strlist_t *src);
+
+SQFS_INTERNAL void strlist_cleanup(strlist_t *list);
+
+SQFS_INTERNAL int strlist_append(strlist_t *list, const char *str);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* UTIL_STRLIST_H */