Memory

Git Source

Modified from skozin's work for Lido. Switch over to the MCOPY instruction once available - https://eips.ethereum.org/EIPS/eip-5656.

Functions

unsafeAllocateBytes

Allocates a memory byte array of len bytes without zeroing it out.

function unsafeAllocateBytes(uint256 len) internal pure returns (bytes memory result);

Parameters

NameTypeDescription

len

uint256

The length of the byte array to allocate.

memcpy

Performs a memory copy of len bytes from position src to position dst.

function memcpy(uint256 src, uint256 dst, uint256 len) internal pure;

Parameters

NameTypeDescription

src

uint256

The source memory position.

dst

uint256

The destination memory position.

len

uint256

The number of bytes to copy.

copyBytes

Copies len bytes from src, starting at position srcStart, into dst, starting at position dstStart into dst.

function copyBytes(bytes memory src, bytes memory dst, uint256 srcStart, uint256 dstStart, uint256 len) internal pure;

Parameters

NameTypeDescription

src

bytes

The source bytes array.

dst

bytes

The destination bytes array.

srcStart

uint256

The starting position in src.

dstStart

uint256

The starting position in dst.

len

uint256

The number of bytes to copy.

copyBytes

Copies bytes from src to dst, starting at position dstStart into dst.

function copyBytes(bytes memory src, bytes memory dst, uint256 dstStart) internal pure;

Parameters

NameTypeDescription

src

bytes

The source bytes array.

dst

bytes

The destination bytes array.

dstStart

uint256

The starting position in dst.

Errors

BYTES_ARRAY_OUT_OF_BOUNDS

Thrown when there is an attempt to access an out of bounds array element.

error BYTES_ARRAY_OUT_OF_BOUNDS();

Last updated