blob: 5590133150ebff6eaafad1a13fb91f28f4d25f0a [file] [log] [blame]
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -07001.\" **************************************************************************
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 Deymo8f1a2142016-06-28 14:49:26 -070012.\" * are also available at https://curl.haxx.se/docs/copyright.html.
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070013.\" *
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 Hughescac39802018-04-27 16:19:43 -070022.TH curl_global_init_mem 3 "February 03, 2016" "libcurl 7.59.0" "libcurl Manual"
Elliott Hughes82be86d2017-09-20 17:00:17 -070023
Lucas Eckels9bd90e62012-08-06 15:07:02 -070024.SH NAME
25curl_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
36This function works exactly as \fIcurl_global_init(3)\fP with one addition: it
37allows the application to set callbacks to replace the otherwise used internal
38memory functions.
39
Alex Deymo8f1a2142016-06-28 14:49:26 -070040If you are using libcurl from multiple threads or libcurl was built with the
41threaded resolver option then the callback functions must be thread safe. The
42threaded resolver is a common build option to enable (and in some cases the
43default) so we strongly urge you to make your callback functions thread safe.
Lucas Eckels9bd90e62012-08-06 15:07:02 -070044
Alex Deymo8f1a2142016-06-28 14:49:26 -070045All callback arguments must be set to valid function pointers. The
46prototypes for the given callbacks must match these:
Lucas Eckels9bd90e62012-08-06 15:07:02 -070047.IP "void *malloc_callback(size_t size);"
48To replace malloc()
49.IP "void free_callback(void *ptr);"
50To replace free()
51.IP "void *realloc_callback(void *ptr, size_t size);"
52To replace realloc()
53.IP "char *strdup_callback(const char *str);"
54To replace strdup()
55.IP "void *calloc_callback(size_t nmemb, size_t size);"
56To replace calloc()
Alex Deymo8f1a2142016-06-28 14:49:26 -070057.RE
58This function is otherwise the same as \fIcurl_global_init(3)\fP, please refer
59to that man page for documentation.
Lucas Eckels9bd90e62012-08-06 15:07:02 -070060.SH "CAUTION"
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070061Manipulating these gives considerable powers to the application to severely
Lucas Eckels9bd90e62012-08-06 15:07:02 -070062screw things up for libcurl. Take care!
63.SH "SEE ALSO"
64.BR curl_global_init "(3), "
65.BR curl_global_cleanup "(3), "
66