[−][src]Function solana_rbpf::helpers::memfrob
pub fn memfrob<E: UserDefinedError>(
addr: u64,
len: u64,
_arg3: u64,
_arg4: u64,
_arg5: u64,
_ro_regions: &[MemoryRegion],
rw_regions: &[MemoryRegion]
) -> Result<u64, EbpfError<E>>
Same as void *memfrob(void *s, size_t n);
in string.h
in C. See the GNU manual page (in
section 3) for memfrob
. The memory is directly modified, and the helper returns 0 in all
cases. Arguments 3 to 5 are unused.
Examples
use solana_rbpf::helpers::memfrob; use solana_rbpf::memory_region::MemoryRegion; use solana_rbpf::user_error::UserError; let val = vec![0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x22, 0x33]; let val_va = 0x1000; let regions = [MemoryRegion::new_from_slice(&val, val_va)]; memfrob::<UserError>(val_va, 8, 0, 0, 0, ®ions, ®ions); assert_eq!(val, vec![0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x3b, 0x08, 0x19]); memfrob::<UserError>(val_va, 8, 0, 0, 0, ®ions, ®ions); assert_eq!(val, vec![0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x22, 0x33]);