Function solana_program::program_memory::sol_memcpy
source · pub fn sol_memcpy(dst: &mut [u8], src: &[u8], n: usize)
Expand description
Like C memcpy
.
Arguments
dst
- Destinationsrc
- Sourcen
- Number of bytes to copy
Errors
When executed within a BPF 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 BPF 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.