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 /example.c | |
parent | 3c46b13a62164d9f3f99289476f84db7918aafc2 (diff) |
Made connect functions return NULL on alloc failures.
Updated documentation and examples accordingly.
Diffstat (limited to 'example.c')
-rw-r--r-- | example.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -11,8 +11,13 @@ int main(void) { struct timeval timeout = { 1, 500000 }; // 1.5 seconds c = redisConnectWithTimeout((char*)"127.0.0.1", 6379, timeout); - if (c->err) { - printf("Connection error: %s\n", c->errstr); + if (c == NULL || c->err) { + if (c) { + printf("Connection error: %s\n", c->errstr); + redisFree(c); + } else { + printf("Connection error: can't allocate redis context\n"); + } exit(1); } |