summaryrefslogtreecommitdiff
path: root/event.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-11-25 17:14:19 +0000
committerNick Mathewson <nickm@torproject.org>2007-11-25 17:14:19 +0000
commit7eb250e9c52813f30fef256b97f08a6871fd381a (patch)
tree434da79bcc882cb0d88a7db1ad71003b51aad091 /event.h
parent98b5453ecdd6a474ba8c3495285e607d5b7a8e57 (diff)
downloadlibevent-7eb250e9c52813f30fef256b97f08a6871fd381a.tar.gz
r14939@tombo: nickm | 2007-11-25 11:59:26 -0500
New function event_set_mem_functions to replace internal calls to malloc, free, etc with a user-supplied functions. svn:r541
Diffstat (limited to 'event.h')
-rw-r--r--event.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/event.h b/event.h
index b9d74976..bbbbcacc 100644
--- a/event.h
+++ b/event.h
@@ -1105,6 +1105,27 @@ int evtag_unmarshal_string(struct evbuffer *evbuf, ev_uint8_t need_tag,
int evtag_unmarshal_timeval(struct evbuffer *evbuf, ev_uint8_t need_tag,
struct timeval *ptv);
+/**
+ Override the functions that libevent uses for memory management.
+
+ Usually, libevent uses the standard libc functions malloc, realloc, and
+ free to allocate memory. Passing replacements for those functions to
+ event_set_mem_functions() overrides this behavior. To restore the default
+ behavior, pass NULLs as the arguments to this function.
+
+ Note that all memory returned from libevent will be allocated by the
+ replacement functions rather than by malloc() and realloc(). Thus, if you
+ have replaced those functions, it may not be appropriate to free() memory
+ that you get from libevent.
+
+ @param malloc_fn A replacement for malloc.
+ @param realloc_fn A replacement for realloc
+ @param free_fn A replacement for free.
+ **/
+void event_set_mem_functions(void *(*malloc_fn)(size_t sz),
+ void *(*realloc_fn)(void *ptr, size_t sz),
+ void (*free_fn)(void *ptr));
+
#ifdef __cplusplus
}
#endif