Apply minor readability fixes

This commit is contained in:
Kai Wolf
2019-02-23 17:28:20 +01:00
parent 527ee8eace
commit ff22e75f95
24 changed files with 219 additions and 166 deletions
+10 -7
View File
@@ -7,10 +7,10 @@
#endif
extern bool json_parse(const char * buf, size_t len, ParsedJson &pj, bool reallocifneeded);
extern bool json_parse(const std::string_view &s, ParsedJson &pj, bool reallocifneeded);
extern ParsedJson build_parsed_json(const char * buf, size_t len, bool reallocifneeded);
extern ParsedJson build_parsed_json(const std::string_view &s, bool reallocifneeded);
// parse a document found in buf, need to preallocate ParsedJson.
@@ -34,7 +34,8 @@ bool json_parse(const uint8_t *buf, size_t len, ParsedJson &pj, bool reallocifne
if ( (reinterpret_cast<uintptr_t>(buf + len - 1) % pagesize ) < SIMDJSON_PADDING ) {
const uint8_t *tmpbuf = buf;
buf = (uint8_t *) allocate_padded_buffer(len);
if(buf == NULL) return false;
if(buf == nullptr) { return false;
}
memcpy((void*)buf,tmpbuf,len);
reallocated = true;
}
@@ -43,10 +44,12 @@ bool json_parse(const uint8_t *buf, size_t len, ParsedJson &pj, bool reallocifne
if (isok) {
isok = unified_machine(buf, len, pj);
} else {
if(reallocated) free((void*)buf);
if(reallocated) { free((void*)buf);
}
return false;
}
if(reallocated) free((void*)buf);
if(reallocated) { free((void*)buf);
}
return isok;
}