]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: virstring: Remove virStringListJoin
authorPeter Krempa <pkrempa@redhat.com>
Fri, 5 Feb 2021 20:35:21 +0000 (21:35 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 11 Feb 2021 16:05:34 +0000 (17:05 +0100)
The glib alternative is now used everywhere.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/libvirt_private.syms
src/util/virstring.c
src/util/virstring.h
tests/virstringtest.c

index ce48ecfda00108dc0b01d1ae8b5fe753c38c8594..dcc613ca255b7f881f39d9a4e66450ebc1f0062c 100644 (file)
@@ -3241,7 +3241,6 @@ virStringHasSuffix;
 virStringIsEmpty;
 virStringIsPrintable;
 virStringListFreeCount;
-virStringListJoin;
 virStringListMerge;
 virStringMatch;
 virStringMatchesNameSuffix;
index 89d9ba4a13a8a99716a8964e1de221e39cc39edd..c98435388a7b4b950da6f88d3800f58b3f87872f 100644 (file)
 
 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
index 48b20f5c7d9e429ba99dc75c71b22904e4a0bc7b..45aead1838657e5a466c217766791d9308d2ad50 100644 (file)
@@ -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);
 
index 238cb9d79eac81e782ec0522ecd3cb956d780386..3bd9b97db72826cb423319e2889c2c359daa1d58 100644 (file)
@@ -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