From: Osier Yang Date: Wed, 11 Apr 2012 14:40:34 +0000 (+0800) Subject: qemu: Avoid the memory allocation and freeing X-Git-Tag: v0.9.12-rc1~88 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6fbd5737e9cebe7ea7caa9459ca6bc3200ff5440;p=thirdparty%2Flibvirt.git qemu: Avoid the memory allocation and freeing --- diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index b6132d282d..f468c092d0 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1759,23 +1759,19 @@ static char * qemuGetNumadAdvice(virDomainDefPtr def) { virCommandPtr cmd = NULL; - char *args = NULL; char *output = NULL; - if (virAsprintf(&args, "%d:%llu", def->vcpus, def->mem.cur_balloon) < 0) { - virReportOOMError(); - goto out; - } - cmd = virCommandNewArgList(NUMAD, "-w", args, NULL); + cmd = virCommandNewArgList(NUMAD, "-w", NULL); + virCommandAddArgFormat(cmd, "%d:%llu", def->vcpus, + def->mem.cur_balloon); virCommandSetOutputBuffer(cmd, &output); if (virCommandRun(cmd, NULL) < 0) qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Failed to query numad for the advisory nodeset")); + _("Failed to query numad for the " + "advisory nodeset")); -out: - VIR_FREE(args); virCommandFree(cmd); return output; }