-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Add extra memory manipulation functions #5792
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
base: master
Are you sure you want to change the base?
Add extra memory manipulation functions #5792
Conversation
Co-authored-by: Hadrien Croubois <[email protected]>
Co-authored-by: Arr00 <[email protected]>
This reverts commit 3847050.
🦋 Changeset detectedLatest commit: 7158817 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
/// @dev Returns a `Pointer` to the `value`'s header (i.e. includes the length word). | ||
function asPointer(bytes memory value) internal pure returns (Pointer) { | ||
bytes32 ptr; | ||
assembly ("memory-safe") { | ||
ptr := value | ||
} | ||
return asPointer(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.
/// @dev Returns a `Pointer` to the `value`'s header (i.e. includes the length word). | |
function asPointer(bytes memory value) internal pure returns (Pointer) { | |
bytes32 ptr; | |
assembly ("memory-safe") { | |
ptr := value | |
} | |
return asPointer(ptr); | |
} | |
/// @dev Returns a `Pointer` to the `value`'s header (i.e. includes the length word). | |
function asPointer(bytes memory value) internal pure returns (Pointer ptr) { | |
assembly ("memory-safe") { | |
ptr := value | |
} | |
} |
In #5680, I introduced an approach based on "memory slices", similar to calldata slice. That may be a (safer?) alternate to pure memory pointers |
Depends on #5189
PR Checklist
npx changeset add
)