#include <curl/curl.h>

CURLcode curl_global_init_mem(long flags, curl_malloc_callback m, curl_free_callback f,
curl_realloc_callback r, curl_strdup_callback s, curl_calloc_callback c );


flags Flags that initialize the program environment that libcurl needs.
m Callback to replace malloc.
f Callback to replace free.
r Callback to replace realloc.
s Callback to replace strdup.
c Callback to replace calloc.

Return Values

If the operation was successful, CURLE_OK is returned. Otherwise, a specific libcurl Error Code is returned.


This function works exactly as curl_global_init with one addition: it allows the application to set callbacks to replace the otherwise used internal memory functions.

This MAN page only adds documentation for the callbacks, see the curl_global_init MAN page for more information. When you use this function, all callback arguments must be set to valid function pointers.

The prototypes for the given callbacks should match the following.

To replace malloc

void *malloc_callback(size_t size);

To replace free

void free_callback(void *ptr);

To replace realloc

void *realloc_callback(void *ptr, size_t size);

To replace strdup

char *strdup_callback(const char *str);

To replace calloc

void *calloc_callback(size_t nmemb, size_t size);

Manipulating these parameters provides considerable powers to the application that can severely affect events for libcurl. Use with caution.

Do Not Call From


See Also

HTTP Client Library (libcurl)
libcurl API Functions
libcurl Error Codes

Revision History

2013/09/18 Conversion
2013/05/08 Automated cleanup pass.
2012/05/04 Initial version.