Specifying alignment of blocks


Expert opinions:

  • Niall Douglas: I would favour option 1, then 3 and none of the others. The problem with option 2 – although aesthetically preferable and much more consistent with how alignment is used throughout the C standard – is that it would require the rewriting of the small block implementation and some surgery performed throughout all memory allocators, and I don’t think the major OS vendors will stomach that. I would favour option 1 over 3 because the new alignof() implicity function in C1X allows the very natural mem = malloc2(sizeof(T), alignof(T), 0) whereas option 3 would mean mem = malloc2(sizeof(T), M2_ALIGN(alignof(T))).

Post a Comment

Required fields are marked *

*
*

%d bloggers like this: