Skip to main content

ddwaf_user_allocator_init

Function ddwaf_user_allocator_init 

Source
pub unsafe extern "C" fn ddwaf_user_allocator_init(
    alloc_fn: ddwaf_alloc_fn_type,
    free_fn: ddwaf_free_fn_type,
    udata: *mut c_void,
    udata_free_fn: ddwaf_udata_free_fn_type,
) -> ddwaf_allocator
Expand description

Creates an allocator that forwards allocation and deallocation to user provided callbacks.

@param alloc_fn Allocation callback. It receives the opaque udata, the requested size and alignment, and must return a pointer meeting the alignment requirements or NULL on failure. (nonnull) @param free_fn Deallocation callback. It receives the opaque udata, the pointer to free, and the original size and alignment. It must be able to free any pointer previously returned by alloc_fn. (nonnull) @param udata Opaque user pointer forwarded to both callbacks; can be used to carry custom state. (nullable) @param udata_free_fn User data destruction callback, used to perform any relevant destruction and reclamation operations on the provided user data.

@return Allocator handle.