diff options
author | Jan-Erik Rediger <janerik@fnordig.de> | 2016-03-26 01:02:48 +0100 |
---|---|---|
committer | Jan-Erik Rediger <janerik@fnordig.de> | 2016-03-26 01:02:48 +0100 |
commit | 1b8ed38843319e17c54021a3b2a9b496159ebdcb (patch) | |
tree | aa6171a4d846fe250d962e846db3be37ec2a38b0 /README.md | |
parent | db1c46dac7f0c54310e05a682cc444b7ae287dcf (diff) |
docs: Handle NULL in example
Closes #361
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -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"); + } } ``` |