diff options
author | antirez <antirez@gmail.com> | 2011-05-27 15:39:31 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2011-07-15 17:58:22 +0200 |
commit | d30dafe7f49c55e2cf51409986869c2b134c7672 (patch) | |
tree | c725f34de66a3771936a81c77f824ad4157802f4 | |
parent | a906670e2d074bf74070b9a0a2f086d1f3777703 (diff) | |
download | redis-d30dafe7f49c55e2cf51409986869c2b134c7672.tar.gz |
use the new rewriteClientCommandVector() function for SPOP -> SREM replication translation as well.
-rw-r--r-- | src/networking.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/networking.c b/src/networking.c index 7d4b96364..e837ee148 100644 --- a/src/networking.c +++ b/src/networking.c @@ -897,3 +897,27 @@ void rewriteClientCommandVector(redisClient *c, int argc, ...) { va_end(ap); } +void rewriteClientCommandVector(redisClient *c, int argc, ...) { + va_list ap; + int j; + robj **argv; /* The new argument vector */ + + argv = zmalloc(sizeof(robj*)*argc); + va_start(ap,argc); + for (j = 0; j < argc; j++) { + robj *a; + + a = va_arg(ap, robj*); + argv[j] = a; + incrRefCount(a); + } + /* We free the objects in the original vector at the end, so we are + * sure that if the same objects are reused in the new vector the + * refcount gets incremented before it gets decremented. */ + for (j = 0; j < c->argc; j++) decrRefCount(c->argv[j]); + zfree(c->argv); + /* Replace argv and argc with our new versions. */ + c->argv = argv; + c->argc = argc; + va_end(ap); +} |