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
+5 -1
View File
@@ -67,7 +67,7 @@ object "test_11" {
function allocateMemory(size) -> memPtr {
memPtr := mload(64)
let newFreePtr := add(memPtr, size)
let newFreePtr := add(memPtr, round_up_to_mul_of_32(size))
// protect against overflow
if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() }
mstore(64, newFreePtr)
@@ -93,6 +93,10 @@ object "test_11" {
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 :=