| 1 |
.\" ************************************************************************** |
| 2 |
.\" * _ _ ____ _ |
| 3 |
.\" * Project ___| | | | _ \| | |
| 4 |
.\" * / __| | | | |_) | | |
| 5 |
.\" * | (__| |_| | _ <| |___ |
| 6 |
.\" * \___|\___/|_| \_\_____| |
| 7 |
.\" * |
| 8 |
.\" * Copyright (C) 1998 - 2019, Daniel Stenberg, <[email protected]>, et al. |
| 9 |
.\" * |
| 10 |
.\" * This software is licensed as described in the file COPYING, which |
| 11 |
.\" * you should have received as part of this distribution. The terms |
| 12 |
.\" * are also available at https://curl.haxx.se/docs/copyright.html. |
| 13 |
.\" * |
| 14 |
.\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell |
| 15 |
.\" * copies of the Software, and permit persons to whom the Software is |
| 16 |
.\" * furnished to do so, under the terms of the COPYING file. |
| 17 |
.\" * |
| 18 |
.\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 19 |
.\" * KIND, either express or implied. |
| 20 |
.\" * |
| 21 |
.\" ************************************************************************** |
| 22 |
.TH curl_global_init_mem 3 "10 May 2004" "libcurl 7.12.0" "libcurl Manual" |
| 23 |
.SH NAME |
| 24 |
curl_global_init_mem - Global libcurl initialisation with memory callbacks |
| 25 |
.SH SYNOPSIS |
| 26 |
.B #include <curl/curl.h> |
| 27 |
.nf |
| 28 |
.B "CURLcode curl_global_init_mem(long " flags, |
| 29 |
.B " curl_malloc_callback "m, |
| 30 |
.B " curl_free_callback "f, |
| 31 |
.B " curl_realloc_callback "r, |
| 32 |
.B " curl_strdup_callback "s, |
| 33 |
.B " curl_calloc_callback "c ");" |
| 34 |
.SH DESCRIPTION |
| 35 |
This function works exactly as \fIcurl_global_init(3)\fP with one addition: it |
| 36 |
allows the application to set callbacks to replace the otherwise used internal |
| 37 |
memory functions. |
| 38 |
|
| 39 |
If you are using libcurl from multiple threads or libcurl was built with the |
| 40 |
threaded resolver option then the callback functions must be thread safe. The |
| 41 |
threaded resolver is a common build option to enable (and in some cases the |
| 42 |
default) so we strongly urge you to make your callback functions thread safe. |
| 43 |
|
| 44 |
All callback arguments must be set to valid function pointers. The |
| 45 |
prototypes for the given callbacks must match these: |
| 46 |
.IP "void *malloc_callback(size_t size);" |
| 47 |
To replace malloc() |
| 48 |
.IP "void free_callback(void *ptr);" |
| 49 |
To replace free() |
| 50 |
.IP "void *realloc_callback(void *ptr, size_t size);" |
| 51 |
To replace realloc() |
| 52 |
.IP "char *strdup_callback(const char *str);" |
| 53 |
To replace strdup() |
| 54 |
.IP "void *calloc_callback(size_t nmemb, size_t size);" |
| 55 |
To replace calloc() |
| 56 |
.RE |
| 57 |
This function is otherwise the same as \fIcurl_global_init(3)\fP, please refer |
| 58 |
to that man page for documentation. |
| 59 |
.SH "CAUTION" |
| 60 |
Manipulating these gives considerable powers to the application to severely |
| 61 |
screw things up for libcurl. Take care! |
| 62 |
.SH AVAILABILITY |
| 63 |
Added in 7.12.0 |
| 64 |
.SH "SEE ALSO" |
| 65 |
.BR curl_global_init "(3), " |
| 66 |
.BR curl_global_cleanup "(3), " |