git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AW: Brigade memory lifetime & leaks



> -----Ursprüngliche Nachricht-----
> Von: Joe Orton <jorton@xxxxxxxxxx>
> Gesendet: Dienstag, 5. Juni 2018 14:48
> An: dev@xxxxxxxxxxxxxxxx; dev@xxxxxxxxxxxxxx
> Betreff: Re: Brigade memory lifetime & leaks
> 
> On Tue, Jun 05, 2018 at 12:07:31PM +0000, Plüm, Rüdiger, Vodafone Group
> wrote:
> > The usual approach in many locations is to store the created bucket
> brigade
> > and reuse it. How about the following (untested):
> 
> Yes, that works too, thanks!  Passes test suite and fixes the leak,
> though I we need to change the _destroy() to be a _cleanup() for safety,
> and add another, as in attached.

Thanks for fleshing it out.

> 
> I think my long standing hatred for this particular function is because
> every single C API ever created in history with a foo_create()
> foo_destroy() pair has memory allocated by the creator and deallocated
> by the destructor.  But this one is special!

Indeed. _destroy is misleading here and should probably go in APR 2 as you
suggest.

> 
> We should remove apr_brigade_destroy() in APR 2, IMO, or switch to
> bucket allocated brigades then.

The question is whether we add them on top to the current ones or as a replacement.

Regards

Rüdiger