cURL / Mailing Lists / curl-library / Single Mail

curl-library

curl_global_init function call

From: Praveen Pvs <meetpraveenpvs_at_gmail.com>
Date: Sun, 15 Nov 2015 15:49:20 +0530

Hi,

Need your guidance on usage of curl_global_init function call?

Do we need to call this function every time or only once at the starting of
the application?

Libcurl manual says

"This function must be called at least once within a program (a program is
all the code that shares a memory space) before the program calls any other
function in libcurl. The environment it sets up is constant for the life of
the program and is the same for every program, so multiple calls have the
same effect as one call."

Does it mean that once in whole application? What if i have different
threads which make libcurl function calls? Do i need to make
curl_global_init function call in each of this thread?

In our design - the business logic thread creates online transaction thread
whose job is post the current transaction to the host. and we have one more
thread offline transaction whose job is re-post the details once host is up.

We are making curl_global_init function call in each of these threads in
addition to one at start of the call. Do we need to call curl_global_cleanup
when we are existing from this thread.

Will there be memory leak if we dont call curl_global_cleanup function
before exiting the online thread?

I am chasing memory leaks in our application, any guidelines to avoid
memory leaks while curl library will be great help to me.

Thanks for your help and time.

Regards
Praveen

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-11-15