Permalink
Browse files

use the new rewriteClientCommandVector() function for SPOP -> SREM re…

…plication translation as well.
  • Loading branch information...
1 parent a906670 commit d30dafe7f49c55e2cf51409986869c2b134c7672 @antirez committed May 27, 2011
Showing with 24 additions and 0 deletions.
  1. +24 −0 src/networking.c
View
@@ -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);
+}

0 comments on commit d30dafe

Please sign in to comment.