Hmm, in this case, overriding the macro to modify the parameters would be tough to get correct. Since the macros are variadic, the caller may or may not supply a params struct. You would need to do some fancy footwork to handle both cases.
If all you wanted to do was globally enable bounds checks, the way he ended up doing it (by or-ing in the flag inside PushSize_) seems like the easiest way to go about it. You could wrap that statement in an #ifdef, macroize the rvalue, and have yourself a party. For example,
| #ifdef EXTRA_ALLOCATION_FLAGS
Arena->AllocationFlags |= EXTRA_ALLOCATION_FLAGS;
#endif
if (Arena->AllocationFlags & (PlatformMemory_OverflowCheck | PlatformMemory_UnderflowCheck)) {
...
|
Of course, the downside to this approach is you give up granular control over who gets these flags and who doesn't. Presumably, you macroized the callsites to give yourself the option of easily switching the checks on for a particular file or block of code (or for some other, unknown reason). The code above is an all-or-nothing deal.
Looking at it further, the allocation flags live outside the params structure (for whatever reason), so I think you could use something like the following if you wanted more control,
| #define PushSize(Arena, Size, ...) (((Arena)->AllocationFlags |= <flags>), PushSize_(Arena, Size, ## __VA_ARGS__))
|
Maybe that is one reason to #define all your allocators?