Skip to main content

CAlloc

Function CAlloc 

Source
pub unsafe extern "C" fn CAlloc(
    nitems: usize,
    size: usize,
) -> *mut c_void
Expand description

Allocates zero-initialized memory for an array of elements.

This function has the same behavior as calloc, except that it does not return on allocation failure. If memory cannot be allocated, an error message is written to standard error and the process terminates.

Parameters:

  • nitems: Number of elements to allocate.
  • size: Size in bytes of each element.

Returns:

  • A pointer to zero-initialized memory on success.
  • NULL if size is zero.

Ownership: The caller owns the returned memory and must release it using free.

Safety notes for FFI:

  • This function never returns on out-of-memory conditions.
  • It does not set errno.
  • Callers must not assume recoverable failure semantics.