Trait method lrs::alloc::Allocator::reallocate_raw

Reallocates a chunk of bytes.

Syntax

unsafe fn reallocate_raw(pool: &mut <Self as Allocator>::Pool, ptr: *mut u8, oldsize: usize, newsize: usize, alignment: usize) -> Result<*mut u8, Errno>

Arguments

NameDescription
pool

The pool from which to draw memory.

ptr

The pointer that should be reallocated.

oldsize

The previous size of the allocation.

newsize

The new size.

alignment

The alignment of the allocation.

Return value

Returns the new object.

Remarks

The pointer argument must have been returned by a previous invocation of allocate_raw or reallocate_raw with the same allocator and pool. The alignment argument must be the same alignment that was previously used to allocate the object. The oldsize argument must be the current size of the object.

Otherwise the behavior is undefined.

If this function returns successfully, the pointer argument becomes invalid and must no longer be used. Otherwise the pointer argument can continued to be used.

If the function returns successfully, the first oldsize bytes in the new object are the same as the first oldsize bytes in the old object.

If newsize is 0, the behavior is undefined.