mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Round up allocations to multiples of 32.
This commit is contained in:
committed by
Alex Beregszaszi
parent
31ee06d945
commit
db4b39e09e
@@ -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) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user