logos.lang.mem

Module lang · package logos-lang

Functions

fnalloc

fn alloc(size: i64) -> *mut u8

Allocates size bytes of uninitialized memory. Returns null on allocation failure.

fncompare_bytes

fn compare_bytes(a: *const u8, b: *const u8, n: i64) -> i32

Compares n bytes at a and b; returns negative, zero, or positive (as memcmp).

fncopy_bytes

fn copy_bytes(dst: *mut u8, src: *const u8, n: i64) -> void

Copies n bytes from src to dst; regions must not overlap (use move_bytes if they may).

fndealloc

fn dealloc(ptr: *mut u8) -> void

Frees memory previously returned by alloc or realloc_buf. Null is a no-op.

fnfill_bytes

fn fill_bytes(ptr: *mut u8, val: i32, n: i64) -> void

Fills n bytes starting at ptr with val (low 8 bits used).

fnmove_bytes

fn move_bytes(dst: *mut u8, src: *const u8, n: i64) -> void

Copies n bytes from src to dst; safe for overlapping regions.

fnrealloc_buf

fn realloc_buf(ptr: *mut u8, size: i64) -> *mut u8

Resizes the allocation at ptr to size bytes, moving it if necessary. Returns the new pointer; on failure returns null and leaves the original allocation intact.

fnreplace

fn replace(ptr: *mut T, new_val: T) -> T

Replaces the value at ptr with new_val, returning the old value.

fnreplace_ref

fn replace_ref(dst: &mut T, src: T) -> T

Moves src into dst, returning the previous value at dst.

fnswap

fn swap(a: *mut T, b: *mut T) -> void

Swaps the values at two non-overlapping pointers of the same type.

fnswap_ref

fn swap_ref(a: &mut T, b: &mut T) -> void

Swaps the values behind two exclusive references.

fntake

fn take(ptr: *mut T) -> T

Replaces the value at ptr with T::default(), returning the old value. Useful for moving ownership out of a container field without a partial-move borrowck error.

fntake_ref

fn take_ref(dst: &mut T) -> T

Moves the value out of dst, replacing it with T::default().

fnzero_bytes

fn zero_bytes(ptr: *mut u8, n: i64) -> void

Zeroes n bytes starting at ptr.