summaryrefslogtreecommitdiff
path: root/hiredis.c
diff options
context:
space:
mode:
Diffstat (limited to 'hiredis.c')
-rw-r--r--hiredis.c30
1 files changed, 9 insertions, 21 deletions
diff --git a/hiredis.c b/hiredis.c
index 8eabac0..98f43c9 100644
--- a/hiredis.c
+++ b/hiredis.c
@@ -84,16 +84,14 @@ void freeReplyObject(void *reply) {
case REDIS_REPLY_ARRAY:
if (r->element != NULL) {
for (j = 0; j < r->elements; j++)
- if (r->element[j] != NULL)
- freeReplyObject(r->element[j]);
+ freeReplyObject(r->element[j]);
free(r->element);
}
break;
case REDIS_REPLY_ERROR:
case REDIS_REPLY_STATUS:
case REDIS_REPLY_STRING:
- if (r->str != NULL)
- free(r->str);
+ free(r->str);
break;
}
free(r);
@@ -432,11 +430,7 @@ cleanup:
}
sdsfree(curarg);
-
- /* No need to check cmd since it is the last statement that can fail,
- * but do it anyway to be as defensive as possible. */
- if (cmd != NULL)
- free(cmd);
+ free(cmd);
return error_type;
}
@@ -612,18 +606,12 @@ void redisFree(redisContext *c) {
return;
if (c->fd > 0)
close(c->fd);
- if (c->obuf != NULL)
- sdsfree(c->obuf);
- if (c->reader != NULL)
- redisReaderFree(c->reader);
- if (c->tcp.host)
- free(c->tcp.host);
- if (c->tcp.source_addr)
- free(c->tcp.source_addr);
- if (c->unix_sock.path)
- free(c->unix_sock.path);
- if (c->timeout)
- free(c->timeout);
+ sdsfree(c->obuf);
+ redisReaderFree(c->reader);
+ free(c->tcp.host);
+ free(c->tcp.source_addr);
+ free(c->unix_sock.path);
+ free(c->timeout);
free(c);
}