mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-26 23:55:23 +00:00
util: conf: use g_new0
Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
576e0ce64a
commit
b5682a1330
@ -163,8 +163,7 @@ virConfNew(void)
|
|||||||
{
|
{
|
||||||
virConfPtr ret;
|
virConfPtr ret;
|
||||||
|
|
||||||
if (VIR_ALLOC(ret) < 0)
|
ret = g_new0(virConf, 1);
|
||||||
return NULL;
|
|
||||||
ret->filename = NULL;
|
ret->filename = NULL;
|
||||||
ret->flags = 0;
|
ret->flags = 0;
|
||||||
|
|
||||||
@ -219,8 +218,7 @@ virConfAddEntry(virConfPtr conf, char *name, virConfValuePtr value, char *comm)
|
|||||||
if (name)
|
if (name)
|
||||||
VIR_DEBUG("Add entry %s %p", name, value);
|
VIR_DEBUG("Add entry %s %p", name, value);
|
||||||
|
|
||||||
if (VIR_ALLOC(ret) < 0)
|
ret = g_new0(virConfEntry, 1);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
ret->name = name;
|
ret->name = name;
|
||||||
ret->value = value;
|
ret->value = value;
|
||||||
@ -522,11 +520,7 @@ virConfParseValue(virConfParserCtxtPtr ctxt)
|
|||||||
virConfError(ctxt, VIR_ERR_CONF_SYNTAX, _("expecting a value"));
|
virConfError(ctxt, VIR_ERR_CONF_SYNTAX, _("expecting a value"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (VIR_ALLOC(ret) < 0) {
|
ret = g_new0(virConfValue, 1);
|
||||||
virConfFreeList(lst);
|
|
||||||
VIR_FREE(str);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
ret->type = type;
|
ret->type = type;
|
||||||
ret->l = l;
|
ret->l = l;
|
||||||
ret->str = str;
|
ret->str = str;
|
||||||
@ -947,8 +941,7 @@ int virConfGetValueStringList(virConfPtr conf,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC_N(*values, len + 1) < 0)
|
*values = g_new0(char *, len + 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
for (len = 0, eval = cval->list; eval; len++, eval = eval->next)
|
for (len = 0, eval = cval->list; eval; len++, eval = eval->next)
|
||||||
(*values)[len] = g_strdup(eval->str);
|
(*values)[len] = g_strdup(eval->str);
|
||||||
@ -956,8 +949,7 @@ int virConfGetValueStringList(virConfPtr conf,
|
|||||||
|
|
||||||
case VIR_CONF_STRING:
|
case VIR_CONF_STRING:
|
||||||
if (compatString) {
|
if (compatString) {
|
||||||
if (VIR_ALLOC_N(*values, cval->str ? 2 : 1) < 0)
|
*values = g_new0(char *, cval->str ? 2 : 1);
|
||||||
return -1;
|
|
||||||
if (cval->str)
|
if (cval->str)
|
||||||
(*values)[0] = g_strdup(cval->str);
|
(*values)[0] = g_strdup(cval->str);
|
||||||
break;
|
break;
|
||||||
@ -1356,10 +1348,7 @@ virConfSetValue(virConfPtr conf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!cur) {
|
if (!cur) {
|
||||||
if (VIR_ALLOC(cur) < 0) {
|
cur = g_new0(virConfEntry, 1);
|
||||||
virConfFreeValue(value);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
cur->comment = NULL;
|
cur->comment = NULL;
|
||||||
cur->name = g_strdup(setting);
|
cur->name = g_strdup(setting);
|
||||||
cur->value = value;
|
cur->value = value;
|
||||||
|
Loading…
Reference in New Issue
Block a user