Re: [PATCH] Remove MemPools use of calloc()

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Sun, 13 Jan 2013 16:07:05 -0700

On 01/12/2013 04:05 PM, Amos Jeffries wrote:
> On 13/01/2013 6:51 a.m., Alex Rousskov wrote:
>> While you are documenting, it may be a good idea to explain that we zero
>> on push because we are afraid of broken code using stale/dirty data
>> after the memory was returned to the pool. If we were not afraid of
>> that, we would zero on allocate() instead!

> Will do.
>
> I think we do not need to have that worry anymore with the C++ compiler
> and Coverity use-after-free checks. Do you agree?

I do not know. However, if we do have code accessing free memory, I
think it may be better to let that code crash or misbehave than to
continue hiding such accesses from ourselves.

The third patch version look OK to me (although I would probably keep
zeroBlocks(bool) setter non-inlined). If you decide to switch to the
zero-on-allocate path, your patch will need to be adjusted again, of course!

Thank you,

Alex.
Received on Sun Jan 13 2013 - 23:07:14 MST

This archive was generated by hypermail 2.2.0 : Mon Jan 14 2013 - 12:00:06 MST