pub unsafe fn realloc(
scrap_heap: NonNull<ScrapHeap>,
new_layout: Layout,
) -> Result<(NonNull<ScrapHeap>, NonNull<u8>), AllocError>
Expand description
Attempts to reallocate memory previously allocated from a thread-local scrap heap.
§Errors
Returns a pair of non-null pointers to the scrap heap and the newly allocated memory on success,
or an AllocError
if reallocation fails.
The old memory region is not automatically copied or deallocated.
§Safety
old_ptr
must be a pointer previously returned byalloc
oralloc_zeroed
using the same scrap heap and layout.- The caller is responsible for copying any existing data and deallocating the old pointer if needed.
- The returned memory is uninitialized.
This function behaves more like a fresh allocation than a standard realloc.