mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
@@ -0,0 +1 @@
|
||||
-1
|
||||
+5
-3
@@ -35,9 +35,11 @@ ParsedJson::ParsedJson(ParsedJson && p)
|
||||
|
||||
WARN_UNUSED
|
||||
bool ParsedJson::allocateCapacity(size_t len, size_t maxdepth) {
|
||||
if ((maxdepth == 0) || (len == 0)) {
|
||||
std::cerr << "capacities must be non-zero " << std::endl;
|
||||
return false;
|
||||
if (maxdepth <= 0) {
|
||||
maxdepth = 1; // don't let the user allocate nothing
|
||||
}
|
||||
if (len <= 0) {
|
||||
len = 64; // allocating 0 bytes is wasteful.
|
||||
}
|
||||
if(len > SIMDJSON_MAXSIZE_BYTES) {
|
||||
return false;
|
||||
|
||||
+2
-2
@@ -86,8 +86,8 @@ int main(int argc, char *argv[]) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
int res = simdjson::json_parse(p, pj); // do the parsing, return false on error
|
||||
if (res) {
|
||||
std::cerr << " Parsing failed. " << std::endl;
|
||||
if (res != simdjson::SUCCESS) {
|
||||
std::cerr << " Parsing failed. Error is '" << simdjson::errorMsg(res) << "'." << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (apidump) {
|
||||
|
||||
@@ -46,6 +46,7 @@ stat_t simdjson_computestats(const simdjson::padded_string &p) {
|
||||
simdjson::ParsedJson pj = simdjson::build_parsed_json(p);
|
||||
answer.valid = pj.isValid();
|
||||
if (!answer.valid) {
|
||||
std::cerr << pj.getErrorMsg() << std::endl;
|
||||
return answer;
|
||||
}
|
||||
answer.backslash_count = count_backslash(reinterpret_cast<const uint8_t*>(p.data()), p.size());
|
||||
|
||||
Reference in New Issue
Block a user