Round up allocations to multiples of 32.

This commit is contained in:
chriseth
2021-01-14 21:52:17 +00:00
committed by Alex Beregszaszi
parent 31ee06d945
commit db4b39e09e
20 changed files with 86 additions and 58 deletions
@@ -43,7 +43,7 @@ object \"C_7\" {
function allocateMemory(size) -> memPtr
{
memPtr := mload(64)
let newFreePtr := add(memPtr, size)
let newFreePtr := add(memPtr, round_up_to_mul_of_32(size))
if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() }
mstore(64, newFreePtr)
}
@@ -55,6 +55,10 @@ object \"C_7\" {
mstore(4, 0x41)
revert(0, 0x24)
}
function round_up_to_mul_of_32(value) -> result
{
result := and(add(value, 31), not(31))
}
function shift_right_224_unsigned(value) -> newValue
{ newValue := shr(224, value) }
}