#[no_mangle]
pub unsafe extern "C" fn memcmp(
ptr1: *const u8,
ptr2: *const u8,
num: usize,
) -> i32
Expand description
Compares two blocks of memory byte by byte.
This function compares the first num
bytes of the memory blocks pointed to by ptr1
and
ptr2
. If the memory blocks are identical, it returns 0. Otherwise, it returns a positive or
negative value based on the first differing byte.
§Arguments
ptr1
- A pointer to the first memory block.ptr2
- A pointer to the second memory block.num
- The number of bytes to compare.
§Returns
A value indicating the result of the comparison: 0 if the blocks are equal, or the difference between the first differing byte.
§Safety
This function is unsafe because it operates directly on raw pointers.