#![cfg_attr(not(target_family = "unix"), allow(dead_code))]
use std::ptr::NonNull;
pub struct LibcByteSlice {
ptr: NonNull<libc::c_void>,
len: usize,
}
unsafe impl Send for LibcByteSlice {}
unsafe impl Sync for LibcByteSlice {}
impl LibcByteSlice {
pub unsafe fn from_raw_parts(ptr: NonNull<libc::c_void>, len: usize) -> LibcByteSlice {
LibcByteSlice { ptr, len }
}
pub(super) fn as_ptr(&self) -> *mut libc::c_void {
self.ptr.as_ptr()
}
pub(super) fn len(&self) -> usize {
self.len
}
}
impl Drop for LibcByteSlice {
fn drop(&mut self) {
unsafe { libc::free(self.ptr.as_ptr().cast()) }
}
}