summaryrefslogtreecommitdiff
path: root/async.c
diff options
context:
space:
mode:
authorHenri Doreau <henri.doreau@cea.fr>2013-01-22 10:16:30 +0100
committerHenri Doreau <henri.doreau@cea.fr>2013-01-22 10:19:46 +0100
commit814be4f5bd62b4f66281879b3035a20ad84bb498 (patch)
tree4e23740ab761af60b4b21fafe33904d308d2089d /async.c
parent3c46b13a62164d9f3f99289476f84db7918aafc2 (diff)
Made connect functions return NULL on alloc failures.
Updated documentation and examples accordingly.
Diffstat (limited to 'async.c')
-rw-r--r--async.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/async.c b/async.c
index f65f869..b302d82 100644
--- a/async.c
+++ b/async.c
@@ -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;
}