Function tikv_jemalloc_sys::realloc

source ·
pub unsafe extern "C" fn realloc(
    ptr: *mut c_void,
    size: size_t
) -> *mut c_void
Expand description

Resizes the previously-allocated memory region referenced by ptr to size bytes.

Deallocates the old object pointed to by ptr and returns a pointer to a new object that has the size specified by size. The contents of the new object are the same as that of the old object prior to deallocation, up to the lesser of the new and old sizes.

The memory in the new object beyond the size of the old object is uninitialized.

The returned pointer to a new object may have the same value as a pointer to the old object, but realloc may move the memory allocation, resulting in a different return value than ptr.

If ptr is null, realloc behaves identically to malloc for the specified size.

If the size of the space requested is zero, the behavior is implementation-defined: either a null pointer is returned, or the behavior is as if the size were some nonzero value, except that the returned pointer shall not be used to access an object # Errors

Errors

If memory for the new object cannot be allocated, the old object is not deallocated, its value is unchanged, realloc returns null, and errno is set to ENOMEM.

Safety

The behavior is undefined if:

  • ptr does not match a pointer previously returned by the memory allocation functions of this crate, or
  • the memory region referenced by ptr has been deallocated.