From 1b8ed38843319e17c54021a3b2a9b496159ebdcb Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Sat, 26 Mar 2016 01:02:48 +0100 Subject: docs: Handle NULL in example Closes #361 --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4f1a58d..b40cdbb 100644 --- a/README.md +++ b/README.md @@ -48,9 +48,13 @@ After trying to connect to Redis using `redisConnect` you should check the `err` field to see if establishing the connection was successful: ```c redisContext *c = redisConnect("127.0.0.1", 6379); -if (c != NULL && c->err) { - printf("Error: %s\n", c->errstr); - // handle error +if (c == NULL || c->err) { + if (c) { + printf("Error: %s\n", c->errstr); + // handle error + } else { + printf("Can't allocate redis context\n"); + } } ``` -- cgit v1.2.3