diff options
author | Henri Doreau <henri.doreau@cea.fr> | 2013-01-22 10:16:30 +0100 |
---|---|---|
committer | Henri Doreau <henri.doreau@cea.fr> | 2013-01-22 10:19:46 +0100 |
commit | 814be4f5bd62b4f66281879b3035a20ad84bb498 (patch) | |
tree | 4e23740ab761af60b4b21fafe33904d308d2089d /async.c | |
parent | 3c46b13a62164d9f3f99289476f84db7918aafc2 (diff) |
Made connect functions return NULL on alloc failures.
Updated documentation and examples accordingly.
Diffstat (limited to 'async.c')
-rw-r--r-- | async.c | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -142,15 +142,27 @@ static void __redisAsyncCopyError(redisAsyncContext *ac) { } redisAsyncContext *redisAsyncConnect(const char *ip, int port) { - redisContext *c = redisConnectNonBlock(ip,port); - redisAsyncContext *ac = redisAsyncInitialize(c); + redisContext *c; + redisAsyncContext *ac; + + c = redisConnectNonBlock(ip,port); + if (c == NULL) + return NULL; + + ac = redisAsyncInitialize(c); __redisAsyncCopyError(ac); return ac; } redisAsyncContext *redisAsyncConnectUnix(const char *path) { - redisContext *c = redisConnectUnixNonBlock(path); - redisAsyncContext *ac = redisAsyncInitialize(c); + redisContext *c; + redisAsyncContext *ac; + + c = redisConnectUnixNonBlock(path); + if (c == NULL) + return NULL; + + ac = redisAsyncInitialize(c); __redisAsyncCopyError(ac); return ac; } |