You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note new_size: usize instead of new_layout: Layout. This is because this method does not support changing the alignment.
When (re)allocation fails (when the method returns null), the caller typically wants to call handle_alloc_error which takes a Layout. This value needs to be created with code like Layout::from_size_align(new_size, layout.align()).unwrap(). It would be better if the value passed to the error handler was already available. This would be the case if the parameters to realloc were old_size: usize, new_layout: Layout instead.
For the Alloc trait, we could:
Keep consistency with GlobalAlloc, or
Change to old_size: usize, new_layout: Layout, or
If we also decide to lift the same-alignment restriction (which should be discussed in Support reallocating to a different alignment? #5), then the signature becomes old_layout: Layout, new_layout: Layout and this issue is moot.
The
GlobalAlloctrait is stable with this method:(And similarly the
std::alloc::reallocfunction.)Note
new_size: usizeinstead ofnew_layout: Layout. This is because this method does not support changing the alignment.When (re)allocation fails (when the method returns
null), the caller typically wants to callhandle_alloc_errorwhich takes aLayout. This value needs to be created with code likeLayout::from_size_align(new_size, layout.align()).unwrap(). It would be better if the value passed to the error handler was already available. This would be the case if the parameters toreallocwereold_size: usize, new_layout: Layoutinstead.For the
Alloctrait, we could:GlobalAlloc, orold_size: usize, new_layout: Layout, orold_layout: Layout, new_layout: Layoutand this issue is moot.