ruby_xrealloc

Function ruby_xrealloc 

Source
pub unsafe extern "C" fn ruby_xrealloc(
    ptr: *mut c_void,
    newsiz: size_t,
) -> *mut c_void
Expand description

Resize the storage instance.

§@param[in] ptr A valid pointer to a storage instance that was previously returned from either: - ruby_xmalloc(), - ruby_xmalloc2(), - ruby_xcalloc(), - ruby_xrealloc(), or - ruby_xrealloc2(). @param[in] newsiz Requested new amount of memory. @exception rb_eNoMemError No space left for newsiz bytes allocation. @return A valid pointer to a (possibly newly allocated) storage instance; which has at least newsiz bytes width, with appropriate alignment detected by the underlying realloc() routine. @pre The passed pointer must point to a valid live storage instance. It is a failure to pass an already freed pointer. @post In case the function returns the passed pointer as-is, the storage instance that the pointer holds is either grown or shrunken to have at least newsiz bytes. Otherwise a valid pointer to a newly allocated storage instance is returned. In this case ptr is invalidated as if it was passed to ruby_xfree(). @note It doesn’t return NULL. @warning Unlike some realloc() implementations, passing zero to newsiz is not the same as calling ruby_xfree(), because this function never returns NULL. Something meaningful still returns then. @warning It is a failure not to check the return value. Do not assume anything on it. It could be either identical to, or distinct form the passed argument. @warning Do not assume anything on the alignment of the return value. There is no guarantee that it inherits the passed argument’s one. @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 mri-x86_64-linux-gnu-3.2.3