As far as I know, this is the standard way of the memory allocation in assembly:
assembly {
let firstFreeMemoryPointer := mload(0x40)
mstore(0x40, add(firstFreeMemoryPointer, numberOfBytesToAllocate)
}
But I've recently noticed the following example code in the Yul docs:
function allocate(size) -> ptr {
ptr := mload(0x40)
if iszero(ptr) { ptr := 0x60 }
mstore(0x40, add(ptr, size))
}
Does anyone know if this step with checking ptr for zero value (if iszero(ptr) { ptr := 0x60 }
) is required and when can this pointer actually be zero? :)