use the new rewriteClientCommandVector() function for SPOP -> SREM replication translation as well.

This commit is contained in:
antirez
2011-05-27 15:39:31 +02:00
parent 0d119ad3a3
commit 4f8cf6a23c
4 changed files with 32 additions and 36 deletions

View File

@ -947,3 +947,28 @@ void clientCommand(redisClient *c) {
addReplyError(c, "Syntax error, try CLIENT (LIST | KILL ip:port)");
}
}
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);
}