Function rb_sys::bindings::ruby_xcalloc
source · pub unsafe extern "C" fn ruby_xcalloc(
nelems: size_t,
elemsiz: size_t
) -> *mut c_voidExpand description
Identical to ruby_xmalloc2(), except it zero-fills the region before it returns. This could also be seen as a routine identical to ruby_xmalloc(), except it calls calloc() instead of malloc() internally.
- @param
innelems Number of elements. - @param
inelemsiz Size of an element. - @exception
rb_eNoMemErrorNo space left for allocation. - @exception
rb_eArgErrornelems*elemsizwould overflow. - @return A valid pointer to an allocated storage instance; which has at
least
nelems*elemsizbytes width, with appropriate alignment detected by the underlying calloc() routine.
Note
It doesn’t return NULL.
Note
Unlike some calloc() implementations, it allocates something and
returns a meaningful value even when nelems or elemsiz or
both are zero.
Warning
The return value shall be invalidated exactly once by either ruby_xfree(), ruby_xrealloc(), or ruby_xrealloc2(). It is a failure to pass it to system free(), because the system and Ruby might or might not share the same malloc() implementation.
Generated by rb-sys for Ruby 3.0.0