Hi Chris,
I spent a good 45 minutes staring at the code for arena allocation and
trying to find the defect if I changed ptrdiff_t to size_t and I
couldn't eyeball it. I compiled the code and played around with it
calling it with reasonable inputs to no avail. I also reread the
article by Stroustrup to refresh my memory - still couldn't find it.
Would you mind providing a hint?
BTW, a really neat trick to compute the padding. Also, inlining the
assembly to allow the compiler to optimize - brilliant.
Thanks,
Stedman
I'm glad you've given it a shot, Steadman! Hint: Consider what happens in
the "if" condition when the arena is exactly at capacity and a non-zero
number of padding bytes are required for alignment. That is, "padding" is
greater than "avail".