mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-23 11:41:45 +00:00
Implement a mechanism to realloc array buffers; Trap when trying to allocate more than max size; Test allocators in CI
This commit is contained in:
@ -457,7 +457,8 @@ export function allocate_memory(size: usize): usize {
|
||||
|
||||
// search for a suitable block
|
||||
var data: usize = 0;
|
||||
if (size && size <= Block.MAX_SIZE) {
|
||||
if (size) {
|
||||
if (size > Block.MAX_SIZE) unreachable();
|
||||
// 32-bit MAX_SIZE is 1 << 30 and itself aligned, hence the following can't overflow MAX_SIZE
|
||||
size = max<usize>((size + AL_MASK) & ~AL_MASK, Block.MIN_SIZE);
|
||||
|
||||
|
Reference in New Issue
Block a user