]> git.saurik.com Git - redis.git/blobdiff - redis.c
version incremented to 1.050 to distinguish from 1.001 stable and next stable version...
[redis.git] / redis.c
diff --git a/redis.c b/redis.c
index 31402663251a85867bf066776cd5336443d3c466..41ebe18a0c5e17a08d63d03b0bda3e2ca2353ff1 100644 (file)
--- a/redis.c
+++ b/redis.c
@@ -27,7 +27,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#define REDIS_VERSION "1.001"
+#define REDIS_VERSION "1.050"
 
 #include "fmacros.h"
 #include "config.h"
 #define REDIS_STRING 0
 #define REDIS_LIST 1
 #define REDIS_SET 2
-#define REDIS_HASH 3
+#define REDIS_ZSET 3
+#define REDIS_HASH 4
 
 /* Objects encoding */
 #define REDIS_ENCODING_RAW 0    /* Raw representation */
@@ -304,6 +305,11 @@ typedef struct _redisSortOperation {
     robj *pattern;
 } redisSortOperation;
 
+typedef struct zset {
+    dict *dict;
+    tree *tree;
+} zset;
+
 struct sharedObjectsStruct {
     robj *crlf, *ok, *err, *emptybulk, *czero, *cone, *pong, *space,
     *colon, *nullbulk, *nullmultibulk,
@@ -633,6 +639,12 @@ static void redisLog(int level, const char *fmt, ...) {
  * keys and radis objects as values (objects can hold SDS strings,
  * lists, sets). */
 
+static void dictVanillaFree(void *privdata, void *val)
+{
+    DICT_NOTUSED(privdata);
+    zfree(val);
+}
+
 static int sdsDictKeyCompare(void *privdata, const void *key1,
         const void *key2)
 {
@@ -709,6 +721,15 @@ static dictType setDictType = {
     NULL                       /* val destructor */
 };
 
+static dictType zsetDictType = {
+    dictEncObjHash,            /* hash function */
+    NULL,                      /* key dup */
+    NULL,                      /* val dup */
+    dictEncObjKeyCompare,      /* key compare */
+    dictRedisObjectDestructor, /* key destructor */
+    dictVanillaFree            /* val destructor */
+};
+
 static dictType hashDictType = {
     dictObjHash,                /* hash function */
     NULL,                       /* key dup */
@@ -1810,6 +1831,12 @@ static robj *createSetObject(void) {
     return createObject(REDIS_SET,d);
 }
 
+static robj *createZsetObject(void) {
+    dict *d = dictCreate(&zsetDictType,NULL);
+    if (!d) oom("dictCreate");
+    return createObject(REDIS_ZSET,d);
+}
+
 static void freeStringObject(robj *o) {
     if (o->encoding == REDIS_ENCODING_RAW) {
         sdsfree(o->ptr);