solana_program_memory

Function sol_memcpy

Source
pub fn sol_memcpy(dst: &mut [u8], src: &[u8], n: usize)
Expand description

Like C memcpy.

§Arguments

  • dst - Destination
  • src - Source
  • n - Number of bytes to copy

§Errors

When executed within a SBF program, the memory regions spanning n bytes from from the start of dst and src must be mapped program memory. If not, the program will abort.

The memory regions spanning n bytes from dst and src from the start of dst and src must not overlap. If they do, then the program will abort or, if run outside of the SBF VM, will panic.

§Safety

This function is incorrectly missing an unsafe declaration.

This function does not verify that n is less than or equal to the lengths of the dst and src slices passed to it — it will copy bytes to and from beyond the slices.

Specifying an n greater than either the length of dst or src will likely introduce undefined behavior.