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.
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 doesAllocator::{grow,grow_zeroed,shrink}
takenew_layout
instead of justnew_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.