common/cmdparse: no need to use (and leak to) the heap

Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
This commit is contained in:
Sage Weil 2013-06-10 17:11:44 -07:00
parent 5c945cd1b8
commit 6bab425342

View File

@ -138,14 +138,14 @@ cmdmap_from_json(vector<string> cmd, map<string, cmd_vartype> *mapp, stringstrea
// array is a vector of values. Unpack it to a vector
// of strings, the only type we handle.
vector<json_spirit::mValue> spvals = it->second.get_array();
vector<string> *outvp = new vector<string>;
vector<string> outv;
for (vector<json_spirit::mValue>::iterator sv = spvals.begin();
sv != spvals.end(); sv++) {
if (sv->type() != json_spirit::str_type)
throw(runtime_error("Can't handle arrays of non-strings"));
outvp->push_back(sv->get_str());
outv.push_back(sv->get_str());
}
(*mapp)[it->first] = *outvp;
(*mapp)[it->first] = outv;
}
break;
case json_spirit::str_type: