Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx> --- src/util/virconf.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/util/virconf.c b/src/util/virconf.c index 8575dd8849..e983a769ee 100644 --- a/src/util/virconf.c +++ b/src/util/virconf.c @@ -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; -- 2.26.2