This should fix a warning in Visual Studio.

This commit is contained in:
Daniel Lemire 2019-07-31 18:12:58 -04:00
parent bf59ba76f5
commit d83aef4e86
1 changed files with 5 additions and 2 deletions

View File

@ -8,7 +8,8 @@ ParsedJson::Iterator::Iterator(ParsedJson &pj_)
if (!pj.is_valid()) {
throw InvalidJSON();
}
depth_index = new scopeindex_t[pj.depth_capacity];
// we overallocate by "1" to silence a warning in Visual Studio
depth_index = new scopeindex_t[pj.depth_capacity + 1];
// memory allocation would throw
// if(depth_index == nullptr) {
// return;
@ -20,6 +21,8 @@ ParsedJson::Iterator::Iterator(ParsedJson &pj_)
if (current_type == 'r') {
tape_length = current_val & JSON_VALUE_MASK;
if (location < tape_length) {
// If we make it here, then depth_capacity must >=2, but the compiler
// may not know this.
current_val = pj.tape[location];
current_type = (current_val >> 56);
depth++;