aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-05-11 11:30:23 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-05-11 11:30:23 +0000
commitbbafb2eb27954c34967f91c705e74cc0c186970d (patch)
tree5294d3f6b2a9a5e82949cb03cb1733ba833fa9a3 /include
parent434bc13812639c6d76fe4f7b29424b7b21032dc9 (diff)
curl_global_init_mem() allows the memory functions to be replaced.
memory.h is included everywhere for this.
Diffstat (limited to 'include')
-rw-r--r--include/curl/curl.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/include/curl/curl.h b/include/curl/curl.h
index a0ef1a3c6..5f85ffff6 100644
--- a/include/curl/curl.h
+++ b/include/curl/curl.h
@@ -154,6 +154,18 @@ typedef int (*curl_passwd_callback)(void *clientp,
char *buffer,
int buflen);
+/*
+ * The following typedef's are signatures of malloc, free, realloc, strdup and
+ * calloc respectively. Function pointers of these types can be passed to the
+ * curl_global_init_mem() function to set user defined memory management
+ * callback routines.
+ */
+typedef void *(*curl_malloc_callback)(size_t size);
+typedef void (*curl_free_callback)(void *ptr);
+typedef void *(*curl_realloc_callback)(void *ptr, size_t size);
+typedef char *(*curl_strdup_callback)(const char *str);
+typedef void *(*curl_calloc_callback)(size_t nmemb, size_t size);
+
/* the kind of data that is passed to information_callback*/
typedef enum {
CURLINFO_TEXT = 0,
@@ -1013,6 +1025,26 @@ void curl_free(void *p);
CURLcode curl_global_init(long flags);
/*
+ * NAME curl_global_init_mem()
+ *
+ * DESCRIPTION
+ *
+ * curl_global_init() or curl_global_init_mem() should be invoked exactly once
+ * for each application that uses libcurl. This function can be used to
+ * initialize libcurl and set user defined memory management callback
+ * functions. Users can implement memory management routines to check for
+ * memory leaks, check for mis-use of the curl library etc. User registered
+ * callback routines with be invoked by this library instead of the system
+ * memory management routines like malloc, free etc.
+ */
+CURLcode curl_global_init_mem(long flags,
+ curl_malloc_callback m,
+ curl_free_callback f,
+ curl_realloc_callback r,
+ curl_strdup_callback s,
+ curl_calloc_callback c);
+
+/*
* NAME curl_global_cleanup()
*
* DESCRIPTION