-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GlobalAlloc::realloc’s parameters are backward #3
Comments
I like this option the most, as this may be valid for arbitrary allocators. |
Alright, I’ve filed #5 for that discussion. |
#5 is closed, and |
I find it confusing when the |
As the |
The
GlobalAlloc
trait is stable with this method:(And similarly the
std::alloc::realloc
function.)Note
new_size: usize
instead 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_error
which 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 torealloc
wereold_size: usize, new_layout: Layout
instead.For the
Alloc
trait, we could:GlobalAlloc
, orold_size: usize, new_layout: Layout
, orold_layout: Layout, new_layout: Layout
and this issue is moot.The text was updated successfully, but these errors were encountered: