1curl_global_init_mem(3) libcurl Manual curl_global_init_mem(3)
2
3
4
6 curl_global_init_mem - Global libcurl initialisation with memory call‐
7 backs
8
10 #include <curl/curl.h>
11 CURLcode curl_global_init_mem(long flags,
12 curl_malloc_callback m,
13 curl_free_callback f,
14 curl_realloc_callback r,
15 curl_strdup_callback s,
16 curl_calloc_callback c );
17
19 This function works exactly as curl_global_init(3) with one addition:
20 it allows the application to set callbacks to replace the otherwise
21 used internal memory functions.
22
23 If you are using libcurl from multiple threads or libcurl was built
24 with the threaded resolver option then the callback functions must be
25 thread safe. The threaded resolver is a common build option to enable
26 (and in some cases the default) so we strongly urge you to make your
27 callback functions thread safe.
28
29 All callback arguments must be set to valid function pointers. The pro‐
30 totypes for the given callbacks must match these:
31
32 void *malloc_callback(size_t size);
33 To replace malloc()
34
35 void free_callback(void *ptr);
36 To replace free()
37
38 void *realloc_callback(void *ptr, size_t size);
39 To replace realloc()
40
41 char *strdup_callback(const char *str);
42 To replace strdup()
43
44 void *calloc_callback(size_t nmemb, size_t size);
45 To replace calloc()
46This function is otherwise the same as curl_global_init(3), please refer to
47that man page for documentation.
48
50 Manipulating these gives considerable powers to the application to se‐
51 verely screw things up for libcurl. Take care!
52
54 curl_global_init(3), curl_global_cleanup(3),
55
56
57
58libcurl 7.64.0 September 23, 2018 curl_global_init_mem(3)