Skip to main content

expand

Function expand 

Source
pub unsafe fn expand(p: *mut u8, new_size: usize) -> *mut u8
Expand description

Try to grow an allocation in place, without moving it.

Returns a null pointer if the block cannot be extended where it is — in which case p remains valid and unchanged, unlike rezalloc. Useful when moving would be more expensive than falling back to a different strategy.

§Safety

  • p must be a pointer from this allocator that has not been freed.
  • Unlike rezalloc, p is not consumed: on failure it is still live and must still be freed.