From cafde24a9ad69421b9806303c074bac4cfec319a Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Fri, 5 Feb 2021 21:35:21 +0100 Subject: [PATCH] util: virstring: Remove virStringListJoin The glib alternative is now used everywhere. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/libvirt_private.syms | 1 - src/util/virstring.c | 36 ------------------------------------ src/util/virstring.h | 4 ---- tests/virstringtest.c | 36 ------------------------------------ 4 files changed, 77 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index ce48ecfda0..dcc613ca25 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3241,7 +3241,6 @@ virStringHasSuffix; virStringIsEmpty; virStringIsPrintable; virStringListFreeCount; -virStringListJoin; virStringListMerge; virStringMatch; virStringMatchesNameSuffix; diff --git a/src/util/virstring.c b/src/util/virstring.c index 89d9ba4a13..c98435388a 100644 --- a/src/util/virstring.c +++ b/src/util/virstring.c @@ -35,12 +35,6 @@ VIR_LOG_INIT("util.string"); -/* - * The following virStringSplit & virStringListJoin methods - * are derived from g_strsplit / g_strjoin in glib2, - * also available under the LGPLv2+ license terms - */ - /** * virStringSplitCount: * @@ -61,36 +55,6 @@ virStringSplitCount(const char *string, } -/** - * virStringListJoin: - * @strings: a NULL-terminated array of strings to join - * @delim: a string to insert between each of the strings - * - * Joins a number of strings together to form one long string, with the - * @delim inserted between each of them. The returned string - * should be freed with VIR_FREE(). - * - * Returns: a newly-allocated string containing all of the strings joined - * together, with @delim between them - */ -char *virStringListJoin(const char **strings, - const char *delim) -{ - char *ret; - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - while (*strings) { - virBufferAdd(&buf, *strings, -1); - if (*(strings+1)) - virBufferAdd(&buf, delim, -1); - strings++; - } - ret = virBufferContentAndReset(&buf); - if (!ret) - ret = g_strdup(""); - return ret; -} - - /** * virStringListMerge: * @dst: a NULL-terminated array of strings to expand diff --git a/src/util/virstring.h b/src/util/virstring.h index 48b20f5c7d..45aead1838 100644 --- a/src/util/virstring.h +++ b/src/util/virstring.h @@ -28,10 +28,6 @@ char **virStringSplitCount(const char *string, size_t *tokcount) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4); -char *virStringListJoin(const char **strings, - const char *delim) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); - int virStringListMerge(char ***dst, char ***src); diff --git a/tests/virstringtest.c b/tests/virstringtest.c index 238cb9d79e..3bd9b97db7 100644 --- a/tests/virstringtest.c +++ b/tests/virstringtest.c @@ -82,12 +82,6 @@ struct testSplitData { }; -struct testJoinData { - const char *string; - const char *delim; - const char **tokens; -}; - static int testSplit(const void *args) { const struct testSplitData *data = args; @@ -140,29 +134,6 @@ static int testSplit(const void *args) } -static int testJoin(const void *args) -{ - const struct testJoinData *data = args; - char *got; - int ret = -1; - - if (!(got = virStringListJoin(data->tokens, data->delim))) { - VIR_DEBUG("Got no result"); - return -1; - } - if (STRNEQ(got, data->string)) { - fprintf(stderr, "Mismatch '%s' vs '%s'\n", got, data->string); - goto cleanup; - } - - ret = 0; - cleanup: - VIR_FREE(got); - - return ret; -} - - static int testStringSortCompare(const void *opaque G_GNUC_UNUSED) { @@ -606,15 +577,8 @@ mymain(void) .max_tokens = max, \ .tokens = toks, \ }; \ - struct testJoinData joinData = { \ - .string = str, \ - .delim = del, \ - .tokens = toks, \ - }; \ if (virTestRun("Split " #str, testSplit, &splitData) < 0) \ ret = -1; \ - if (virTestRun("Join " #str, testJoin, &joinData) < 0) \ - ret = -1; \ } while (0) VIR_WARNINGS_NO_DECLARATION_AFTER_STATEMENT