1curl_global_init_mem(3)         libcurl Manual         curl_global_init_mem(3)
2
3
4

NAME

6       curl_global_init_mem  - Global libcurl initialization with memory call‐
7       backs
8

SYNOPSIS

10       #include <curl/curl.h>
11
12       CURLcode curl_global_init_mem(long flags,
13                                     curl_malloc_callback m,
14                                     curl_free_callback f,
15                                     curl_realloc_callback r,
16                                     curl_strdup_callback s,
17                                     curl_calloc_callback c);
18

DESCRIPTION

20       This function works exactly as curl_global_init(3) with  one  addition:
21       it  allows  the  application  to set callbacks to replace the otherwise
22       used internal memory functions.
23
24       If you are using libcurl from multiple threads  or  libcurl  was  built
25       with  the  threaded resolver option then the callback functions must be
26       thread safe. The threaded resolver is a common build option  to  enable
27       (and  in  some  cases the default) so we strongly urge you to make your
28       callback functions thread safe.
29
30       All callback arguments must be set to valid function pointers. The pro‐
31       totypes for the given callbacks must match these:
32
33       void *malloc_callback(size_t size);
34              To replace malloc()
35
36       void free_callback(void *ptr);
37              To replace free()
38
39       void *realloc_callback(void *ptr, size_t size);
40              To replace realloc()
41
42       char *strdup_callback(const char *str);
43              To replace strdup()
44
45       void *calloc_callback(size_t nmemb, size_t size);
46              To replace calloc()
47
48       This  function is otherwise the same as curl_global_init(3), please re‐
49       fer to that man page for documentation.
50

CAUTION

52       Manipulating these gives considerable powers to the application to  se‐
53       verely screw things up for libcurl. Take care!
54

EXAMPLE

56        curl_global_init_mem(CURL_GLOBAL_DEFAULT, curl_malloc_cb,
57                             curl_free_cb, curl_realloc_cb,
58                             curl_strdup_cb, curl_calloc_cb);
59

AVAILABILITY

61       Added in 7.12.0
62

RETURN VALUE

64       CURLE_OK  (0) means everything was ok, non-zero means an error occurred
65       as <curl/curl.h> defines - see libcurl-errors(3).
66

SEE ALSO

68       curl_global_init(3), curl_global_cleanup(3),
69
70
71
72libcurl 7.85.0                   May 17, 2022          curl_global_init_mem(3)
Impressum