From 814be4f5bd62b4f66281879b3035a20ad84bb498 Mon Sep 17 00:00:00 2001 From: Henri Doreau Date: Tue, 22 Jan 2013 10:16:30 +0100 Subject: Made connect functions return NULL on alloc failures. Updated documentation and examples accordingly. --- example.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'example.c') diff --git a/example.c b/example.c index 378ef71..d9d7271 100644 --- a/example.c +++ b/example.c @@ -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); } -- cgit v1.2.3