Function rb_sys::bindings::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.
  • @retval ptr 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.
  • @retval otherwise A valid pointer to a newly allocated storage instance which has at least newsiz bytes width, and holds previous contents of ptr. 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 elemsiz 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 3.0.0