Function rb_sys::bindings::ruby_xmalloc
source · pub unsafe extern "C" fn ruby_xmalloc(size: size_t) -> *mut c_voidExpand description
Allocates a storage instance. It is largely the same as system malloc(), except:
-
It raises Ruby exceptions instead of returning NULL, and
-
In case of
ENOMEMit tries to GC to make some room. -
@param
insize Requested amount of memory. -
@exception
rb_eNoMemErrorNo space left forsizebytes allocation. -
@return A valid pointer to an allocated storage instance; which has at least
sizebytes width, with appropriate alignment detected by the underlying malloc() routine.
Note
It doesn’t return NULL.
Note
Unlike some malloc() implementations, it allocates something and
returns a meaningful value even when size is equal to 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