summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Stancliff <matt@genges.com>2015-01-05 10:40:58 -0500
committerMatt Stancliff <matt@genges.com>2015-01-05 16:39:30 -0500
commit9a753b42519a6d0f1998ff5b1c09e63fcc72749a (patch)
tree574b68dcd34bee9f6cef06b44d3cd54aef702e88
parent1b392eb796ed3853392109dfadb34a98fa37d61b (diff)
Add API to free hiredis (sds) formattings
External callers may not know about sdsfree, so let's give them an easy way to know how to free their sds result.
-rw-r--r--hiredis.c4
-rw-r--r--hiredis.h1
2 files changed, 5 insertions, 0 deletions
diff --git a/hiredis.c b/hiredis.c
index 34198fc..3a70e1d 100644
--- a/hiredis.c
+++ b/hiredis.c
@@ -984,6 +984,10 @@ int redisFormatSdsCommandArgv(sds *target, int argc, const char **argv,
return totlen;
}
+void redisFreeSdsCommand(sds cmd) {
+ sdsfree(cmd);
+}
+
/* Format a command according to the Redis protocol. This function takes the
* number of arguments, an array with arguments and an array with their
* lengths. If the latter is set to NULL, strlen will be used to compute the
diff --git a/hiredis.h b/hiredis.h
index c9f4a00..114b9ae 100644
--- a/hiredis.h
+++ b/hiredis.h
@@ -171,6 +171,7 @@ int redisFormatCommand(char **target, const char *format, ...);
int redisFormatCommandArgv(char **target, int argc, const char **argv, const size_t *argvlen);
int redisFormatSdsCommandArgv(sds *target, int argc, const char ** argv, const size_t *argvlen);
void redisFreeCommand(char *cmd);
+void redisFreeSdsCommand(sds cmd);
/* Context for a connection to Redis */
typedef struct redisContext {