Skip to content

Commit

Permalink
There is no longer need for a separate redisDisconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
pietern committed Nov 1, 2010
1 parent 30a9f8f commit 5fa8d30
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 1 addition & 6 deletions hiredis.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion hiredis.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5fa8d30

Please sign in to comment.