summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md30
1 files changed, 30 insertions, 0 deletions
diff --git a/README.md b/README.md
index d5ed553..3fc3418 100644
--- a/README.md
+++ b/README.md
@@ -500,6 +500,36 @@ if (redisInitiateSSLWithContext(c, ssl) != REDIS_OK) {
}
```
+## Allocator injection
+
+Hiredis uses a pass-thru structure of function pointers defined in
+[alloc.h](https://github.com/redis/hiredis/blob/f5d25850/alloc.h#L41) that conttain
+the currently configured allocation and deallocation functions. By default they
+just point to libc (`malloc`, `calloc`, `realloc`, etc).
+
+### Overriding
+
+One can override the allocators like so:
+
+```c
+hiredisAllocFuncs myfuncs = {
+ .mallocFn = my_malloc,
+ .callocFn = my_calloc,
+ .reallocFn = my_realloc,
+ .strdupFn = my_strdup,
+ .freeFn = my_free,
+};
+
+// Override allocators (function returns current allocators if needed)
+hiredisAllocFuncs orig = hiredisSetAllocators(&myfuncs);
+```
+
+To reset the allocators to their default libc function simply call:
+
+```c
+hiredisResetAllocators();
+```
+
## AUTHORS
Hiredis was written by Salvatore Sanfilippo (antirez at gmail) and