From 7f89eb3cfff465cf32d03a2ae6919252eae67e9b Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Thu, 21 Sep 2023 15:53:14 +0200 Subject: libutil: add a string list helper to replace some of the adhoc ones Signed-off-by: David Oberhollenzer --- include/util/strlist.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 include/util/strlist.h (limited to 'include/util') 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 + */ +#ifndef UTIL_STRLIST_H +#define UTIL_STRLIST_H + +#include "sqfs/predef.h" +#include + +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 */ -- cgit v1.2.3