Sortix cross-nightly manual
This manual documents Sortix cross-nightly. You can instead view this document in the latest official manual.
| curl_global_init_mem(3) | Library Functions Manual | curl_global_init_mem(3) |
NAME
curl_global_init_mem - global libcurl initialization with memory callbacksSYNOPSIS
#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);
DESCRIPTION
This function works exactly as curl_global_init(3) with one addition: it allows the application to set callbacks to replace the otherwise used internal memory functions.- void *malloc_callback(size_t size);
- To replace malloc()
- void free_callback(void *ptr);
- To replace free()
- void *realloc_callback(void *ptr, size_t size);
- To replace realloc()
- char *strdup_callback(const char *str);
- To replace strdup()
- void *calloc_callback(size_t nmemb, size_t size);
-
To replace calloc()This function is otherwise the same as curl_global_init(3), please refer to that man page for documentation.
CAUTION
Manipulating these gives considerable powers to the application to severely screw things up for libcurl. Take care.PROTOCOLS
This functionality affects all supported protocolsEXAMPLE
extern void *malloc_cb(size_t);
extern void free_cb(void *);
extern void *realloc_cb(void *, size_t);
extern char *strdup_cb(const char *);
extern void *calloc_cb(size_t, size_t);
int main(void)
{
curl_global_init_mem(CURL_GLOBAL_DEFAULT, malloc_cb,
free_cb, realloc_cb,
strdup_cb, calloc_cb);
}
AVAILABILITY
Added in curl 7.12.0RETURN VALUE
CURLE_OK (0) means everything was OK, non-zero means an error occurred as <curl/curl.h> defines - see libcurl-errors(3).SEE ALSO
curl_global_cleanup(3), curl_global_init(3)| 2025-10-24 | libcurl |