mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
Adding dynamic memory allocation.
This commit is contained in:
@@ -23,3 +23,15 @@ bool json_parse(const u8 *buf, size_t len, ParsedJson &pj) {
|
||||
return isok;
|
||||
}
|
||||
|
||||
WARN_UNUSED
|
||||
ParsedJson build_parsed_json(const u8 *buf, size_t len) {
|
||||
ParsedJson pj;
|
||||
bool ok = pj.allocateCapacity(len);
|
||||
if(ok) {
|
||||
ok = json_parse(buf, len, pj);
|
||||
assert(ok == pj.isValid());
|
||||
} else {
|
||||
std::cerr << "failure during memory allocation " << std::endl;
|
||||
}
|
||||
return pj;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user