xmlXPathContextPtr ctxt,
void **data)
{
- qemuDomainXmlNsDefPtr cmd = NULL;
- bool uses_qemu_ns = false;
+ qemuDomainXmlNsDefPtr nsdata = NULL;
+ int ret = -1;
if (xmlXPathRegisterNs(ctxt, BAD_CAST "qemu", BAD_CAST QEMU_NAMESPACE_HREF) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
return -1;
}
- if (VIR_ALLOC(cmd) < 0)
+ if (VIR_ALLOC(nsdata) < 0)
return -1;
- if (qemuDomainDefNamespaceParseCommandlineArgs(cmd, ctxt) < 0 ||
- qemuDomainDefNamespaceParseCommandlineEnv(cmd, ctxt) < 0)
- goto error;
-
- if (cmd->num_args > 0 || cmd->num_env > 0)
- uses_qemu_ns = true;
+ if (qemuDomainDefNamespaceParseCommandlineArgs(nsdata, ctxt) < 0 ||
+ qemuDomainDefNamespaceParseCommandlineEnv(nsdata, ctxt) < 0)
+ goto cleanup;
- if (uses_qemu_ns)
- *data = cmd;
- else
- VIR_FREE(cmd);
+ if (nsdata->num_args > 0 || nsdata->num_env > 0)
+ VIR_STEAL_PTR(*data, nsdata);
- return 0;
+ ret = 0;
- error:
- qemuDomainDefNamespaceFree(cmd);
- return -1;
+ cleanup:
+ qemuDomainDefNamespaceFree(nsdata);
+ return ret;
}
static int