cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Wonder on curl_easy_getinfo()

From: Jason Pump <jpump_at_mindspring.com>
Date: Wed, 09 Aug 2006 13:47:24 -0700

You are creating the long ( with "= new long"), not curl; so if you
want, you should clean it up. Curl is not returning any memory, merely
using the memory you have allocated for it.

Cyril Picat wrote:
> Hi,
>
> I am quite new with libcurl and I am currently using
> version 7.15.4, compiling it in C++.
> I have a wonder on curl_easy_get_info(): I am using it
> at the end of a transfer (I use the multi interface to
> manage all easy handles in one thread) to check the
> HTTP status code. I am doing something like :
>
> long* lRespCode = new long;
> curl_easy_getinfo(curl_easy,
> CURLINFO_RESPONSE_CODE, lRespCode);
>
> In a first time, looking at the documentation of
> curl_easy_get_info(), I was not deleting the pointer
> to the long because of the sentence 'You should not
> free the memory returned by this function unless it is
> explictly mentioned below' written in the doc. I was
> assuming that curl was remembering my long* somewhere
> in the easy handle and cleaning it up in
> curl_easy_cleanup().
> But just to be sure, I had a look at the source code
> and and from what I understood the pointer to the
> long* is not kept and thus could not be freed later in
> CURL.
> I did the test with adding 'delete lRespCode;' in my
> code and it works well.
>
> So my question is: am I wrong and, if not, what is the
> exact meaning of this sentence ?
>
> Thanks in advance for your answers,
> And thank you Daniel (and others) for all this great
> work.
>
> Cyril
>
>
>
>
>
>
Received on 2006-08-09