]> git.ozlabs.org Git - ccan/blobdiff - ccan/timer/timer.h
timer: clean up hook allocator API
[ccan] / ccan / timer / timer.h
index 5c40a3bbc1c9979251ad5c2b76ca6a0443c5926a..2eb33c91ca6c49defba32233827e7786b13b7be6 100644 (file)
@@ -162,6 +162,17 @@ 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)
+ *
+ * This replaces the underlying malloc/free with these allocators.
+ * Setting either one to NULL restores the default allocators.
+ */
+void timers_set_allocator(void *(*alloc)(struct timers *, size_t len),
+                         void (*free)(struct timers *, void *p));
+
 #ifdef CCAN_TIMER_DEBUG
 #include <stdio.h>