Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1 | .\" ************************************************************************** |
| 2 | .\" * _ _ ____ _ |
| 3 | .\" * Project ___| | | | _ \| | |
| 4 | .\" * / __| | | | |_) | | |
| 5 | .\" * | (__| |_| | _ <| |___ |
| 6 | .\" * \___|\___/|_| \_\_____| |
| 7 | .\" * |
| 8 | .\" * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, 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 |
Alex Deymo | 8f1a214 | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 12 | .\" * are also available at https://curl.haxx.se/docs/copyright.html. |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 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 | .\" ************************************************************************** |
Elliott Hughes | cac3980 | 2018-04-27 16:19:43 -0700 | [diff] [blame] | 22 | .TH curl_global_init_mem 3 "February 03, 2016" "libcurl 7.59.0" "libcurl Manual" |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 23 | |
Lucas Eckels | 9bd90e6 | 2012-08-06 15:07:02 -0700 | [diff] [blame] | 24 | .SH NAME |
| 25 | curl_global_init_mem - Global libcurl initialisation with memory callbacks |
| 26 | .SH SYNOPSIS |
| 27 | .B #include <curl/curl.h> |
| 28 | .nf |
| 29 | .B "CURLcode curl_global_init_mem(long " flags, |
| 30 | .B " curl_malloc_callback "m, |
| 31 | .B " curl_free_callback "f, |
| 32 | .B " curl_realloc_callback "r, |
| 33 | .B " curl_strdup_callback "s, |
| 34 | .B " curl_calloc_callback "c ");" |
| 35 | .SH DESCRIPTION |
| 36 | This function works exactly as \fIcurl_global_init(3)\fP with one addition: it |
| 37 | allows the application to set callbacks to replace the otherwise used internal |
| 38 | memory functions. |
| 39 | |
Alex Deymo | 8f1a214 | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 40 | If you are using libcurl from multiple threads or libcurl was built with the |
| 41 | threaded resolver option then the callback functions must be thread safe. The |
| 42 | threaded resolver is a common build option to enable (and in some cases the |
| 43 | default) so we strongly urge you to make your callback functions thread safe. |
Lucas Eckels | 9bd90e6 | 2012-08-06 15:07:02 -0700 | [diff] [blame] | 44 | |
Alex Deymo | 8f1a214 | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 45 | All callback arguments must be set to valid function pointers. The |
| 46 | prototypes for the given callbacks must match these: |
Lucas Eckels | 9bd90e6 | 2012-08-06 15:07:02 -0700 | [diff] [blame] | 47 | .IP "void *malloc_callback(size_t size);" |
| 48 | To replace malloc() |
| 49 | .IP "void free_callback(void *ptr);" |
| 50 | To replace free() |
| 51 | .IP "void *realloc_callback(void *ptr, size_t size);" |
| 52 | To replace realloc() |
| 53 | .IP "char *strdup_callback(const char *str);" |
| 54 | To replace strdup() |
| 55 | .IP "void *calloc_callback(size_t nmemb, size_t size);" |
| 56 | To replace calloc() |
Alex Deymo | 8f1a214 | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 57 | .RE |
| 58 | This function is otherwise the same as \fIcurl_global_init(3)\fP, please refer |
| 59 | to that man page for documentation. |
Lucas Eckels | 9bd90e6 | 2012-08-06 15:07:02 -0700 | [diff] [blame] | 60 | .SH "CAUTION" |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 61 | Manipulating these gives considerable powers to the application to severely |
Lucas Eckels | 9bd90e6 | 2012-08-06 15:07:02 -0700 | [diff] [blame] | 62 | screw things up for libcurl. Take care! |
| 63 | .SH "SEE ALSO" |
| 64 | .BR curl_global_init "(3), " |
| 65 | .BR curl_global_cleanup "(3), " |
| 66 | |