Skip to content
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

Why does Allocator::{grow,grow_zeroed,shrink} take new_layout instead of just new_size? #95

Closed
yanchith opened this issue Feb 22, 2022 · 2 comments

Comments

@yanchith
Copy link

yanchith commented Feb 22, 2022

Hey all, a long time lurker here :) Recently I did a small bump allocator (like bumpalo, only much simpler) for a game project I am making, and I wondered about why does Allocator::{grow,grow_zeroed,shrink} take new_layout instead of just new_size.

This allows the caller to request a different-than-original alignment, and while the allocator is allowed to return AllocError if it doesn't want to deal with it, it still needs to at least check, if the alignment requirement didn't increase.

Since I can only imagine contrived uses of changing alignment on the fly, I'd be interested in what was the reasoning for the current design.

@Amanieu
Copy link
Member

Amanieu commented Feb 22, 2022

I think most of the history behind this design is covered in #5.

@yanchith
Copy link
Author

Oh cool, thanks! Great to know that the additional branch will likely get optimized away. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants