diff options
author | Michael Grunder <michael.grunder@gmail.com> | 2020-01-28 12:13:05 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-28 12:13:05 -0800 |
commit | 669ac9d0c843f9ccf07d4969ff6bff75fafee01f (patch) | |
tree | 6075cb357e13342f6844dc9891d6c3c38c8e6f86 /async.c | |
parent | 0501c623c91344e54cb2775a91509650960789b1 (diff) |
Safe allocation wrappers (#754)
Create allocation wrappers with a configurable OOM handler (defaults to abort()).
See #752, #747
Diffstat (limited to 'async.c')
-rw-r--r-- | async.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -30,6 +30,7 @@ */ #include "fmacros.h" +#include "alloc.h" #include <stdlib.h> #include <string.h> #ifndef _MSC_VER @@ -57,7 +58,7 @@ static unsigned int callbackHash(const void *key) { static void *callbackValDup(void *privdata, const void *src) { ((void) privdata); - redisCallback *dup = malloc(sizeof(*dup)); + redisCallback *dup = hi_malloc(sizeof(*dup)); memcpy(dup,src,sizeof(*dup)); return dup; } @@ -754,7 +755,7 @@ int redisAsyncFormattedCommand(redisAsyncContext *ac, redisCallbackFn *fn, void void redisAsyncSetTimeout(redisAsyncContext *ac, struct timeval tv) { if (!ac->c.timeout) { - ac->c.timeout = calloc(1, sizeof(tv)); + ac->c.timeout = hi_calloc(1, sizeof(tv)); } if (tv.tv_sec == ac->c.timeout->tv_sec && |