]> git.saurik.com Git - redis.git/blobdiff - src/db.c
Wrapper for adding unknown multi bulk length to reply list
[redis.git] / src / db.c
index 6d287d72c914762eef4ec17eb08a2f324df71e58..8c6c6bc82d4c2cb2610e692875651e6a59fa7fe7 100644 (file)
--- a/src/db.c
+++ b/src/db.c
@@ -223,11 +223,9 @@ void keysCommand(redisClient *c) {
     sds pattern = c->argv[1]->ptr;
     int plen = sdslen(pattern);
     unsigned long numkeys = 0;
-    robj *lenobj = createObject(REDIS_STRING,NULL);
+    void *replylen = addDeferredMultiBulkLength(c);
 
     di = dictGetIterator(c->db->dict);
-    addReply(c,lenobj);
-    decrRefCount(lenobj);
     while((de = dictNext(di)) != NULL) {
         sds key = dictGetEntryKey(de);
         robj *keyobj;
@@ -243,7 +241,7 @@ void keysCommand(redisClient *c) {
         }
     }
     dictReleaseIterator(di);
-    lenobj->ptr = sdscatprintf(sdsempty(),"*%lu\r\n",numkeys);
+    setDeferredMultiBulkLength(c,replylen,numkeys);
 }
 
 void dbsizeCommand(redisClient *c) {