Re:Bump Allocation: Up or Down?
by celeritascelery on Monday March 25, 2024 @07:53PM
(#39822637)
What other representations of "start/current/end" do you know of? Both versions just use 3 pointers. I am not aware of specific instructions on any architecture that would impact the direction the heap grows. They essentially boil down to adds, subtracts, and and's.
[ Parent
| on HN ]
Re:Bump Allocation: Up or Down?
by JonChesterfield on Tuesday March 26, 2024 @04:12AM
(#39825264)
Start as void*, current and/or end as size_t offsets from start is common.
The opposite way round works too, use a void* for end and current and/or end as offsets from that. 64 bit pointer and two 32 bit offsets might appeal on x64.
Without working through the arithmetic now I'd expect storing (size-current)=remaining instead of current to work well for the out of space check.