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@xxxxxxxxxx> --- src/libvirt_private.syms | 1 - src/util/virjson.c | 21 +-------------------- src/util/virjson.h | 1 - 3 files changed, 1 insertion(+), 22 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b2c16c469d..bf5d0f54f3 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2536,7 +2536,6 @@ virJSONValueNewNumberUint; virJSONValueNewNumberUlong; virJSONValueNewObject; virJSONValueNewString; -virJSONValueNewStringLen; virJSONValueObjectAdd; virJSONValueObjectAddVArgs; virJSONValueObjectAppend; diff --git a/src/util/virjson.c b/src/util/virjson.c index 37301bb87e..719f4de1bf 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -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); diff --git a/src/util/virjson.h b/src/util/virjson.h index 71b88183fe..cb2315d13e 100644 --- a/src/util/virjson.h +++ b/src/util/virjson.h @@ -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); -- 2.31.1