mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 19:32:19 +00:00
util: json: Open-code only call of virJSONValueNewStringLen
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>
This commit is contained in:
parent
a8b4a41731
commit
36d6c3bb67
@ -2536,7 +2536,6 @@ virJSONValueNewNumberUint;
|
||||
virJSONValueNewNumberUlong;
|
||||
virJSONValueNewObject;
|
||||
virJSONValueNewString;
|
||||
virJSONValueNewStringLen;
|
||||
virJSONValueObjectAdd;
|
||||
virJSONValueObjectAddVArgs;
|
||||
virJSONValueObjectAppend;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user