Removing custom types (more standard code).

This commit is contained in:
Daniel Lemire
2018-12-27 20:09:25 -05:00
parent bb83ad47a4
commit bf4089b33b
20 changed files with 284 additions and 309 deletions
+4 -4
View File
@@ -3,7 +3,7 @@
// parse a document found in buf, need to preallocate ParsedJson.
WARN_UNUSED
bool json_parse(const u8 *buf, size_t len, ParsedJson &pj, bool reallocifneeded) {
bool json_parse(const uint8_t *buf, size_t len, ParsedJson &pj, bool reallocifneeded) {
if (pj.bytecapacity < len) {
std::cerr << "Your ParsedJson cannot support documents that big: " << len
<< std::endl;
@@ -14,8 +14,8 @@ bool json_parse(const u8 *buf, size_t len, ParsedJson &pj, bool reallocifneeded)
// realloc is needed if the end of the memory crosses a page
long pagesize = sysconf (_SC_PAGESIZE); // on windows this should be SYSTEM_INFO sysInfo; GetSystemInfo(&sysInfo); sysInfo.dwPageSize
if ( (reinterpret_cast<uintptr_t>(buf + len - 1) % pagesize ) < SIMDJSON_PADDING ) {
const u8 *tmpbuf = buf;
buf = (u8 *) allocate_padded_buffer(len);
const uint8_t *tmpbuf = buf;
buf = (uint8_t *) allocate_padded_buffer(len);
if(buf == NULL) return false;
memcpy((void*)buf,tmpbuf,len);
reallocated = true;
@@ -39,7 +39,7 @@ bool json_parse(const u8 *buf, size_t len, ParsedJson &pj, bool reallocifneeded)
}
WARN_UNUSED
ParsedJson build_parsed_json(const u8 *buf, size_t len, bool reallocifneeded) {
ParsedJson build_parsed_json(const uint8_t *buf, size_t len, bool reallocifneeded) {
ParsedJson pj;
bool ok = pj.allocateCapacity(len);
if(ok) {