Re: Memory leaks using callbacks
Date: Tue, 13 Nov 2007 12:55:31 -0500
On 11/13/07, James Dennett <jdennett_at_technocom-wireless.com> wrote:
> Daniel Stenberg wrote:
> > On Tue, 13 Nov 2007, Raquel Vieira wrote:
> > Please don't top-post:
> > > The variable 'data' is the data that I'm returning from the
> > > I'm deleting that variable in the method httpPost that calls the
> > > callback.
> > Nope. The data is a pointer that is passed to your callback, modifying
> > that
> > won't help. You need to make the pointer point to something in which
> > can
> > return data.
> No; it's a reference to a pointer already (this is C++), and so it does
> modify the caller's pointer. The problem lies elsewhere (though using
> new in this manner from C++ code is cause for concern, at least).
Since it's not a fully self-contained example, making no mention of
whether the callback function is static or not (would be a
requirement, I think), etc, etc, I'll just say that from the looks of
it, it would seem to me that the callback function would leak, if it
is called more than once (not uncommon), before curl_easy_perform()
Received on 2007-11-13