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
@@ -60,7 +60,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))
|
||||
// protect against overflow
|
||||
if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() }
|
||||
mstore(64, newFreePtr)
|
||||
@@ -76,6 +76,10 @@ object \"C_7\" {
|
||||
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 :=
|
||||
|
||||
|
||||
Reference in New Issue
Block a user