mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 23:25:24 +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;
|
||||
|
||||
if (VIR_ALLOC(ret) < 0)
|
||||
return NULL;
|
||||
ret = g_new0(virConf, 1);
|
||||
ret->filename = NULL;
|
||||
ret->flags = 0;
|
||||
|
||||
@ -219,8 +218,7 @@ virConfAddEntry(virConfPtr conf, char *name, virConfValuePtr value, char *comm)
|
||||
if (name)
|
||||
VIR_DEBUG("Add entry %s %p", name, value);
|
||||
|
||||
if (VIR_ALLOC(ret) < 0)
|
||||
return NULL;
|
||||
ret = g_new0(virConfEntry, 1);
|
||||
|
||||
ret->name = name;
|
||||
ret->value = value;
|
||||
@ -522,11 +520,7 @@ virConfParseValue(virConfParserCtxtPtr ctxt)
|
||||
virConfError(ctxt, VIR_ERR_CONF_SYNTAX, _("expecting a value"));
|
||||
return NULL;
|
||||
}
|
||||
if (VIR_ALLOC(ret) < 0) {
|
||||
virConfFreeList(lst);
|
||||
VIR_FREE(str);
|
||||
return NULL;
|
||||
}
|
||||
ret = g_new0(virConfValue, 1);
|
||||
ret->type = type;
|
||||
ret->l = l;
|
||||
ret->str = str;
|
||||
@ -947,8 +941,7 @@ int virConfGetValueStringList(virConfPtr conf,
|
||||
}
|
||||
}
|
||||
|
||||
if (VIR_ALLOC_N(*values, len + 1) < 0)
|
||||
return -1;
|
||||
*values = g_new0(char *, len + 1);
|
||||
|
||||
for (len = 0, eval = cval->list; eval; len++, eval = eval->next)
|
||||
(*values)[len] = g_strdup(eval->str);
|
||||
@ -956,8 +949,7 @@ int virConfGetValueStringList(virConfPtr conf,
|
||||
|
||||
case VIR_CONF_STRING:
|
||||
if (compatString) {
|
||||
if (VIR_ALLOC_N(*values, cval->str ? 2 : 1) < 0)
|
||||
return -1;
|
||||
*values = g_new0(char *, cval->str ? 2 : 1);
|
||||
if (cval->str)
|
||||
(*values)[0] = g_strdup(cval->str);
|
||||
break;
|
||||
@ -1356,10 +1348,7 @@ virConfSetValue(virConfPtr conf,
|
||||
}
|
||||
|
||||
if (!cur) {
|
||||
if (VIR_ALLOC(cur) < 0) {
|
||||
virConfFreeValue(value);
|
||||
return -1;
|
||||
}
|
||||
cur = g_new0(virConfEntry, 1);
|
||||
cur->comment = NULL;
|
||||
cur->name = g_strdup(setting);
|
||||
cur->value = value;
|
||||
|
Loading…
Reference in New Issue
Block a user