phoboslab / wipeout-rewrite

2.61k stars 203 forks source link

Query: mem_temp_alloc 8 bytes alignment of size #68

Closed sujankh closed 10 months ago

sujankh commented 10 months ago

Hi, when looking at the the bump allocator i was assuming the following would modify size to be the next multiple of 8 but looks like it is not.

    size = ((size >> 3) + 7) << 3; // allign to 8 bytes

https://github.com/phoboslab/wipeout-rewrite/blob/ecf1e635082188d3294e10abb255128204854127/src/mem.c#L49

Here is what i see when i add some logs

size: 16  --> becomes: 72
size: 4224  --> becomes: 4280

When user request 16 bytes, do we need to reserve 72 bytes in the temp? We could just reserve 16 bytes right?

phoboslab commented 10 months ago

Good catch, thanks!