提交 7702cc1f 编写于 作者: K Kothapally Madhu Pavan 提交者: John Ferlan

qemu: Move qemuFreeKeywords into qemu_parse_command.c

Move qemuFreeKeywords into qemu_parse_command.c as
qemuParseKeywordsFree and call it rather than inline code
in multiple places.
Signed-off-by: NKothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
上级 09972570
......@@ -468,17 +468,6 @@ qemuMonitorJSONMakeCommandRaw(bool wrap, const char *cmdname, ...)
#define qemuMonitorJSONMakeCommand(cmdname, ...) \
qemuMonitorJSONMakeCommandRaw(false, cmdname, __VA_ARGS__)
static void
qemuFreeKeywords(int nkeywords, char **keywords, char **values)
{
size_t i;
for (i = 0; i < nkeywords; i++) {
VIR_FREE(keywords[i]);
VIR_FREE(values[i]);
}
VIR_FREE(keywords);
VIR_FREE(values);
}
static virJSONValuePtr
qemuMonitorJSONKeywordStringToJSON(const char *str, const char *firstkeyword)
......@@ -513,11 +502,11 @@ qemuMonitorJSONKeywordStringToJSON(const char *str, const char *firstkeyword)
}
}
qemuFreeKeywords(nkeywords, keywords, values);
qemuParseKeywordsFree(nkeywords, keywords, values);
return ret;
error:
qemuFreeKeywords(nkeywords, keywords, values);
qemuParseKeywordsFree(nkeywords, keywords, values);
virJSONValueFree(ret);
return NULL;
}
......
......@@ -381,6 +381,22 @@ static const char *qemuFindEnv(char **progenv,
return NULL;
}
void
qemuParseKeywordsFree(int nkeywords,
char **keywords,
char **values)
{
size_t i;
for (i = 0; i < nkeywords; i++) {
VIR_FREE(keywords[i]);
VIR_FREE(values[i]);
}
VIR_FREE(keywords);
VIR_FREE(values);
}
/*
* Takes a string containing a set of key=value,key=value,key...
* parameters and splits them up, returning two arrays with
......@@ -401,7 +417,6 @@ qemuParseKeywords(const char *str,
char **values = NULL;
const char *start = str;
const char *end;
size_t i;
*retkeywords = NULL;
*retvalues = NULL;
......@@ -479,12 +494,7 @@ qemuParseKeywords(const char *str,
return 0;
error:
for (i = 0; i < keywordCount; i++) {
VIR_FREE(keywords[i]);
VIR_FREE(values[i]);
}
VIR_FREE(keywords);
VIR_FREE(values);
qemuParseKeywordsFree(keywordCount, keywords, values);
return -1;
}
......@@ -949,12 +959,7 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
}
cleanup:
for (i = 0; i < nkeywords; i++) {
VIR_FREE(keywords[i]);
VIR_FREE(values[i]);
}
VIR_FREE(keywords);
VIR_FREE(values);
qemuParseKeywordsFree(nkeywords, keywords, values);
return def;
error:
......@@ -1132,12 +1137,7 @@ qemuParseCommandLineNet(virDomainXMLOptionPtr xmlopt,
virDomainNetGenerateMAC(xmlopt, &def->mac);
cleanup:
for (i = 0; i < nkeywords; i++) {
VIR_FREE(keywords[i]);
VIR_FREE(values[i]);
}
VIR_FREE(keywords);
VIR_FREE(values);
qemuParseKeywordsFree(nkeywords, keywords, values);
return def;
error:
......@@ -1704,13 +1704,7 @@ qemuParseCommandLineMem(virDomainDefPtr dom,
ret = 0;
cleanup:
for (i = 0; i < nkws; i++) {
VIR_FREE(kws[i]);
VIR_FREE(vals[i]);
}
VIR_FREE(kws);
VIR_FREE(vals);
qemuParseKeywordsFree(nkws, kws, vals);
return ret;
}
......@@ -1795,13 +1789,7 @@ qemuParseCommandLineSmp(virDomainDefPtr dom,
ret = 0;
cleanup:
for (i = 0; i < nkws; i++) {
VIR_FREE(kws[i]);
VIR_FREE(vals[i]);
}
VIR_FREE(kws);
VIR_FREE(vals);
qemuParseKeywordsFree(nkws, kws, vals);
return ret;
syntax:
......
......@@ -43,6 +43,11 @@ virDomainDefPtr qemuParseCommandLinePid(virCapsPtr caps,
virDomainChrSourceDefPtr *monConfig,
bool *monJSON);
void
qemuParseKeywordsFree(int nkeywords,
char **keywords,
char **values);
int
qemuParseKeywords(const char *str,
char ***retkeywords,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册