cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Problem with my class in independents threads- Error: "Failure when receiving data from the peer"

From: Kamil Dudka <kdudka_at_redhat.com>
Date: Mon, 27 Jul 2009 10:05:15 +0200

On Monday 27 of July 2009 01:57:40 Denis Bondarev wrote:
> Very -Very thanks!!! Your coments is very actual and real help!!! It is my
> mistake that I a not read documentation is full. Yes your true- I very love
> DELETE operations because no want when memory is gone more and more...:-),
> but in this situation I see that it is mistake too...

Yes, it's good manner to call delete when you no more need an object. I think
you are on the right path. But use it only for objects allocated by the C++
operator new. Otherwise you're in trouble.

For resources managed by curl use the curl API to free them. It doesn't even
work well for memory allocated by malloc(), then you should call
corresponding free().

And as for the local variables (+ fnc args), the return statement is all you
need to free them. The C++ compiler takes also care for calling destructors
of all local objects in reverse order.

Kamil
Received on 2009-07-27