pub struct Allocator {
pub alloc: extern "C" fn(opaque: *mut c_void, size: usize) -> *mut c_void,
pub free: extern "C" fn(opaque: *mut c_void, address: *mut c_void),
pub opaque: *mut c_void,
}Expand description
The allocator a codec’s working state (zstd’s contexts, brotli’s encoder and decoder) comes
from during one call, in the C libraries’ own shape: alloc(opaque, size) and
free(opaque, address). A block must be aligned as malloc() aligns one.
The state is created and freed within the call, as PHP’s extensions create and free theirs, so no state outlives it: a codec behaves as on its first call, even on corrupt input.
Fields§
§alloc: extern "C" fn(opaque: *mut c_void, size: usize) -> *mut c_voidAllocates size bytes, or returns null.
free: extern "C" fn(opaque: *mut c_void, address: *mut c_void)Frees a block alloc returned.
opaque: *mut c_voidPassed to both.
Trait Implementations§
Auto Trait Implementations§
impl !Send for Allocator
impl !Sync for Allocator
impl Forget for Allocator
impl Freeze for Allocator
impl Move for Allocator
impl RefUnwindSafe for Allocator
impl Unpin for Allocator
impl UnsafeUnpin for Allocator
impl UnwindSafe for Allocator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more