News for hackers. Stuff that matters.
Re:Always Bump Downwards (2019) by dev_dwarf on Tuesday September 19, 2023 @02:51PM (#37574483)
Agreed. The question really is if you should demand the user to enforce that constraint on the size they pass to you, or if the function itself should signal an error in that case.
Re:Always Bump Downwards (2019) by loeg on Tuesday September 19, 2023 @04:22PM (#37575963)
I think it would be pretty reasonable to have an input type for that parameter that isn't a full usize and is instead some more restricted type that can only represent smaller values. The alignment parameter could be, like, u8, or maybe u16.
Re:Always Bump Downwards (2019) by dev_dwarf on Tuesday September 19, 2023 @04:45PM (#37576284)
For the alignment parameter I agree.
Re:Always Bump Downwards (2019) by loeg on Tuesday September 19, 2023 @05:38PM (#37577142)
For both.
Re:Always Bump Downwards (2019) by sltkr on Tuesday September 19, 2023 @08:15PM (#37578861)
This still doesn't solve the overflow problem.

It's also too limiting: with u8 you can't ask for page-aligned data, and with u16 not for hugepage-aligned data. Granted, those aren't exactly prime use cases for a bump allocator, but it seems like poor design to limit the API unnecessarily.

Re:Always Bump Downwards (2019) by loeg on Tuesday September 19, 2023 @11:14PM (#37580016)
It fully solves the overflow problem. You don't need page-aligned data in a bump allocator.