| ▲ | phire 4 hours ago | ||||||||||||||||||||||
> so alloc() doesn’t just need to hand back a pointer. it needs to hand back a pointer that’s correctly aligned for whatever type the caller is about to store there. Malloc doesn't know the required alignment (because has no idea what the type is, everything is cast through void). So all malloc implementations have a minimum alignment guarantee. Typically 16 bytes these days on x86, as that means even 128bit SSE values will end up aligned by default. You couldn't go below the sizeof(void ) anyway, the backpointer needs to aligned too. The padding only happens when you use memalign or aligned_malloc to specify a much larger alignment. | |||||||||||||||||||||||
| ▲ | CodesInChaos 4 hours ago | parent [-] | ||||||||||||||||||||||
There is no reason an allocation needs to contain any inline metadata. And even if it does, the allocator could choose to make it unalined, and pay the cost of an unalined access on de-allocation. | |||||||||||||||||||||||
| |||||||||||||||||||||||