diff options
Diffstat (limited to 'deps/hdr_histogram/hdr_alloc.c')
-rw-r--r-- | deps/hdr_histogram/hdr_alloc.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/deps/hdr_histogram/hdr_alloc.c b/deps/hdr_histogram/hdr_alloc.c new file mode 100644 index 000000000..d2bc611d9 --- /dev/null +++ b/deps/hdr_histogram/hdr_alloc.c @@ -0,0 +1,34 @@ +/** + * hdr_alloc.c + * Written by Filipe Oliveira and released to the public domain, + * as explained at http://creativecommons.org/publicdomain/zero/1.0/ + */ + +#include "hdr_alloc.h" +#include <stdlib.h> + +hdrAllocFuncs hdrAllocFns = { + .mallocFn = malloc, + .callocFn = calloc, + .reallocFn = realloc, + .freeFn = free, +}; + +/* Override hdr' allocators with ones supplied by the user */ +hdrAllocFuncs hdrSetAllocators(hdrAllocFuncs *override) { + hdrAllocFuncs orig = hdrAllocFns; + + hdrAllocFns = *override; + + return orig; +} + +/* Reset allocators to use build time defaults */ +void hdrResetAllocators(void) { + hdrAllocFns = (hdrAllocFuncs){ + .mallocFn = malloc, + .callocFn = calloc, + .reallocFn = realloc, + .freeFn = free, + }; +} |