-
Notifications
You must be signed in to change notification settings - Fork 11.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Low level call and memory management #5091
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,22 @@ | ||||||
// SPDX-License-Identifier: MIT | ||||||
|
||||||
pragma solidity ^0.8.20; | ||||||
|
||||||
/** | ||||||
* @dev Helper library for deallocating memory reserved by abi.encode or low level calls. | ||||||
*/ | ||||||
library Memory { | ||||||
type FreePtr is bytes32; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be just
Suggested change
|
||||||
|
||||||
function save() internal pure returns (FreePtr ptr) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, I think this should be very explicit, otherwise reading
Suggested change
|
||||||
assembly ("memory-safe") { | ||||||
ptr := mload(0x40) | ||||||
} | ||||||
} | ||||||
|
||||||
function load(FreePtr ptr) internal pure { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accordingly
Suggested change
|
||||||
assembly ("memory-safe") { | ||||||
mstore(0x40, ptr) | ||||||
} | ||||||
} | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this revert if delay is too large ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
abi.decode
reverts, so I guess we should revert too to keep backwards compatibility