summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter Noordhuis <pcnoordhuis@gmail.com>2010-11-01 14:20:51 +0100
committerPieter Noordhuis <pcnoordhuis@gmail.com>2010-11-01 14:20:51 +0100
commit5fa8d305996ada79f8266ab542df8e9daa80d162 (patch)
tree6244e3c00b4fdc1506d305159ccc4b3d61a5cef1
parent30a9f8f2715cba85cab1f06a4281cb780e198ddb (diff)
There is no longer need for a separate redisDisconnect
-rw-r--r--README.md9
-rw-r--r--hiredis.c7
-rw-r--r--hiredis.h1
3 files changed, 10 insertions, 7 deletions
diff --git a/README.md b/README.md
index 9213382..342217f 100644
--- a/README.md
+++ b/README.md
@@ -107,6 +107,15 @@ Note that this function will take care of freeing sub-replies objects
contained in arrays and nested arrays, so there is no need for the user to
free the sub replies (it is actually harmful and will corrupt the memory).
+### Cleaning up
+
+To disconnect and free the context the following function can be used:
+
+ void redisFree(redisContext *c);
+
+This function immediately closes the socket and then free's the allocations done in
+creating the context.
+
### Sending commands (cont'd)
Together with `redisCommand`, the function `redisCommandArgv` can be used to issue commands.
diff --git a/hiredis.c b/hiredis.c
index ca4cd88..8848def 100644
--- a/hiredis.c
+++ b/hiredis.c
@@ -642,15 +642,10 @@ static redisContext *redisContextInit() {
return c;
}
-void redisDisconnect(redisContext *c) {
- close(c->fd);
- c->flags &= ~REDIS_CONNECTED;
-}
-
void redisFree(redisContext *c) {
/* Disconnect before free'ing if not yet disconnected. */
if (c->flags & REDIS_CONNECTED)
- redisDisconnect(c);
+ close(c->fd);
if (c->error != NULL)
sdsfree(c->error);
if (c->obuf != NULL)
diff --git a/hiredis.h b/hiredis.h
index d149c6f..9ab799e 100644
--- a/hiredis.h
+++ b/hiredis.h
@@ -112,7 +112,6 @@ int redisFormatCommandArgv(char **target, int argc, const char **argv, const siz
redisContext *redisConnect(const char *ip, int port);
redisContext *redisConnectNonBlock(const char *ip, int port);
int redisSetReplyObjectFunctions(redisContext *c, redisReplyObjectFunctions *fn);
-void redisDisconnect(redisContext *c);
void redisFree(redisContext *c);
int redisBufferRead(redisContext *c);
int redisBufferWrite(redisContext *c, int *done);