drogue-ffi-compat 0.1.0

C compatibility shims for FFI integrations
Documentation

/// Exported strlen(const char *s)
#[allow(clippy::not_unsafe_ptr_arg_deref)]
#[no_mangle]
pub extern "C" fn strlen(s: *const u8) -> usize {
    let mut n = 0;
    unsafe {
        while *s.add(n) != 0 {
            n += 1;
        }
    }
    n
}


/// Exported strnlen(const char *s, size_t maxlen)
#[allow(clippy::not_unsafe_ptr_arg_deref)]
#[no_mangle]
pub extern "C" fn strnlen(s: *const u8, maxlen: usize) -> usize {
    let mut n = 0;
    unsafe {
        while *s.add(n) != 0 {
            n += 1;
            if n == maxlen {
                break
            }
        }
    }
    n
}