Function tikv_jemalloc_sys::xallocx
source · [−]pub unsafe extern "C" fn xallocx(
ptr: *mut c_void,
size: size_t,
extra: size_t,
flags: c_int
) -> size_t
Expand description
Resizes the previously-allocated memory region referenced by ptr
in
place to be at least size
bytes, returning the real size of the
allocation.
Deallocates the old object pointed to by ptr
and sets ptr
to a new
object that has the size returned; the old a new objects share the same
base address. 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.
If extra
is non-zero, an attempt is made to resize the allocation to
be at least size + extra
bytes. Inability to allocate the extra
bytes will not by itself result in failure to resize.
The memory in the new object beyond the size of the old object is
obtained according to flags
(it might be uninitialized).
Errors
If the allocation cannot be adequately grown in place up to size
, the
size returned is smaller than size
.
Note:
- the size value returned can be larger than the size requested during allocation
- when shrinking an allocation, use the size returned to determine whether the allocation was shrunk sufficiently or not.
Safety
The behavior is undefined if:
size == 0
, orsize + extra > size_t::max_value()
, orptr
does not match a pointer earlier returned by the memory allocation functions of this crate, or- the memory region referenced by
ptr
has been deallocated.