Add memrchr()
This commit is contained in:
committed by
Mateusz Mikuła
parent
15aa52a8e9
commit
d62db7b1b9
@@ -107,6 +107,20 @@ pub unsafe extern "C" fn memmove(s1: *mut c_void, s2: *const c_void, n: size_t)
|
||||
s1
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn memrchr(
|
||||
haystack: *const c_void,
|
||||
needle: c_int,
|
||||
len: size_t,
|
||||
) -> *mut c_void {
|
||||
let haystack = slice::from_raw_parts(haystack as *const u8, len as usize);
|
||||
|
||||
match memchr::memrchr(needle as u8, haystack) {
|
||||
Some(index) => haystack[index..].as_ptr() as *mut c_void,
|
||||
None => ptr::null_mut(),
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn memset(s: *mut c_void, c: c_int, n: size_t) -> *mut c_void {
|
||||
for i in 0..n {
|
||||
|
||||
Reference in New Issue
Block a user