Skip to main content

ddwaf_allocator_alloc

Function ddwaf_allocator_alloc 

Source
pub unsafe extern "C" fn ddwaf_allocator_alloc(
    alloc: ddwaf_allocator,
    bytes: usize,
    alignment: usize,
) -> *mut c_void
Expand description

Allocates a block of memory from the given allocator with the requested alignment.

Usage and guarantees:

  • The returned pointer is aligned to alignment bytes.
  • Returns NULL on allocation failure.
  • Memory obtained with this function must be released with ddwaf_allocator_free using the same allocator and the same bytes and alignment values.
  • Thread-safety depends on the allocator type; see the corresponding allocator init function for details.

@param alloc Allocator to use for the allocation. (nonnull) @param bytes Number of bytes to allocate. @param alignment Required alignment in bytes; must be a power of two.

@return Pointer to the allocated memory or NULL on failure.