X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/37dc9e5abbb9335ee3217e8295bd37d051dc16a4..c7019f7019a7ded425e700f391263227e259bbcb:/redis-cli.c

diff --git a/redis-cli.c b/redis-cli.c
index 08c8e2d5..2daa7c46 100644
--- a/redis-cli.c
+++ b/redis-cli.c
@@ -252,18 +252,17 @@ static int cliSendCommand(int argc, char **argv, int repeat) {
         return 1;
     }
 
+    /* Build the command to send */
+    cmd = sdscatprintf(sdsempty(),"*%d\r\n",argc);
+    for (j = 0; j < argc; j++) {
+        cmd = sdscatprintf(cmd,"$%lu\r\n",
+            (unsigned long)sdslen(argv[j]));
+        cmd = sdscatlen(cmd,argv[j],sdslen(argv[j]));
+        cmd = sdscatlen(cmd,"\r\n",2);
+    }
+
     while(repeat--) {
-        /* Build the command to send */
-        cmd = sdscatprintf(sdsempty(),"*%d\r\n",argc);
-        for (j = 0; j < argc; j++) {
-            cmd = sdscatprintf(cmd,"$%lu\r\n",
-                (unsigned long)sdslen(argv[j]));
-            cmd = sdscatlen(cmd,argv[j],sdslen(argv[j]));
-            cmd = sdscatlen(cmd,"\r\n",2);
-        }
         anetWrite(fd,cmd,sdslen(cmd));
-        sdsfree(cmd);
-
         while (config.monitor_mode) {
             cliReadSingleLineReply(fd,0);
         }
@@ -277,7 +276,6 @@ static int cliSendCommand(int argc, char **argv, int repeat) {
         }
 
         retval = cliReadReply(fd);
-
         if (retval) {
             return retval;
         }