Squashed 'lispBM/lispBM/' changes from 3c02bc6f..fdbe8699

fdbe8699 One comment
53c4495e One instance of off-by-one found

git-subtree-dir: lispBM/lispBM
git-subtree-split: fdbe869982229d2516faaf9cbdf55dca3d11b838
This commit is contained in:
Benjamin Vedder 2022-04-13 22:16:39 +02:00
parent 9d539909ef
commit 3dd2f879e0
1 changed files with 13 additions and 2 deletions

View File

@ -729,8 +729,19 @@ bool parse_array(lbm_tokenizer_char_stream_t *str, lbm_uint initial_size, lbm_va
ix++;
}
lbm_memory_shrink((lbm_uint*)arr->data, t == LBM_TYPE_BYTE ? ix / 4 : (ix - 1));
arr->size = ix - 1;
lbm_uint array_size = ix - 1;
// Calculate array size in number of words
if (t = LBM_TYPE_BYTE) {
if (array_size % 4) {
array_size = (array_size / 4) + 1;
} else {
array_size = array_size / 4;
}
}
lbm_memory_shrink((lbm_uint*)arr->data, array_size);
arr->size = ix - 1;
*res = array;
return true;
}