~skeeto/public-inbox

1

Arena allocation

Steadman Dillroper <dillstead@gmail.com>
Details
Message ID
<CAOJH3v5275PcV9heccdPo77=WzQq2xZQuyrkYHUi1nJ-XBC5kQ@mail.gmail.com>
DKIM signature
missing
Download raw message
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
Details
Message ID
<20230930014459.rzw3te4r2hruvv4w@nullprogram.com>
In-Reply-To
<CAOJH3v5275PcV9heccdPo77=WzQq2xZQuyrkYHUi1nJ-XBC5kQ@mail.gmail.com> (view parent)
DKIM signature
missing
Download raw message
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".
Reply to thread Export thread (mbox)