]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: json: Open-code only call of virJSONValueNewStringLen
authorPeter Krempa <pkrempa@redhat.com>
Mon, 20 Dec 2021 13:56:13 +0000 (14:56 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 22 Dec 2021 12:48:35 +0000 (13:48 +0100)
Replace the function by a call to virJSONValueNewString, when we copy
the string using g_strndup. Remove the unused helper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
src/libvirt_private.syms
src/util/virjson.c
src/util/virjson.h

index b2c16c469d80fbf60636790aa25f1eb533cded43..bf5d0f54f3d7fad55facb4af26067de5ce7852b0 100644 (file)
@@ -2536,7 +2536,6 @@ virJSONValueNewNumberUint;
 virJSONValueNewNumberUlong;
 virJSONValueNewObject;
 virJSONValueNewString;
-virJSONValueNewStringLen;
 virJSONValueObjectAdd;
 virJSONValueObjectAddVArgs;
 virJSONValueObjectAppend;
index 37301bb87e907ce7bfe25e3d89ec99c3763d2ba5..719f4de1bf6f3493fcca0389aa7537a6939453bc 100644 (file)
@@ -428,24 +428,6 @@ virJSONValueNewString(char *data)
 }
 
 
-virJSONValue *
-virJSONValueNewStringLen(const char *data,
-                         size_t length)
-{
-    virJSONValue *val;
-
-    if (!data)
-        return virJSONValueNewNull();
-
-    val = g_new0(virJSONValue, 1);
-
-    val->type = VIR_JSON_TYPE_STRING;
-    val->data.string = g_strndup(data, length);
-
-    return val;
-}
-
-
 /**
  * virJSONValueNewNumber:
  * @data: string representing the number
@@ -1558,8 +1540,7 @@ virJSONParserHandleString(void *ctx,
                           size_t stringLen)
 {
     virJSONParser *parser = ctx;
-    g_autoptr(virJSONValue) value = virJSONValueNewStringLen((const char *)stringVal,
-                                                             stringLen);
+    g_autoptr(virJSONValue) value = virJSONValueNewString(g_strndup((const char *)stringVal, stringLen));
 
     VIR_DEBUG("parser=%p str=%p", parser, (const char *)stringVal);
 
index 71b88183fed40d67ee633ae16818c8e51da45346..cb2315d13ee2a3817bdffc7f5cf638f78235c039 100644 (file)
@@ -51,7 +51,6 @@ int virJSONValueObjectAddVArgs(virJSONValue **objptr, va_list args)
 
 
 virJSONValue *virJSONValueNewString(char *data);
-virJSONValue *virJSONValueNewStringLen(const char *data, size_t length);
 virJSONValue *virJSONValueNewNumberInt(int data);
 virJSONValue *virJSONValueNewNumberUint(unsigned int data);
 virJSONValue *virJSONValueNewNumberLong(long long data);