cURL / Mailing Lists / curl-library / Single Mail

curl-library

Wonder on curl_easy_getinfo()

From: Cyril Picat <cpicat_at_paraxip.com>
Date: Wed, 9 Aug 2006 12:50:50 -0700 (PDT)

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