]> git.ozlabs.org Git - ccan/blobdiff - ccan/timer/timer.h
timer: add hook for allocation functions.
[ccan] / ccan / timer / timer.h
index 5c40a3bbc1c9979251ad5c2b76ca6a0443c5926a..5b193250da58308f63ec98b46d3d15496e1fe049 100644 (file)
@@ -162,6 +162,19 @@ struct timer *timers_expire(struct timers *timers, struct timemono expire);
  */
 struct timers *timers_check(const struct timers *t, const char *abortstr);
 
+/**
+ * timers_set_allocator - set malloc/free functions.
+ * @alloc: allocator to use
+ * @free: unallocator to use (@p is NULL or a return from @alloc)
+ * @arg: argument to pass.
+ *
+ * This replaces the underlying malloc/free with these allocators.
+ * Setting either one to NULL restores the default allocators.
+ */
+void timers_set_allocator(void *(*alloc)(size_t len, void *arg),
+                         void (*free)(const void *p, void *arg),
+                         void *arg);
+
 #ifdef CCAN_TIMER_DEBUG
 #include <stdio.h>