summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2011-11-08 19:41:29 +0100
committerantirez <antirez@gmail.com>2011-11-08 19:41:29 +0100
commitaa9a61ccd7cc1ffa1441ef74edd9d51954fc7896 (patch)
tree115ebd6e10bf805a80e75f61891fb93e73270078
parentc0ba9ebe13865189a3b21f7be8a910e349b59fda (diff)
downloadredis-aa9a61ccd7cc1ffa1441ef74edd9d51954fc7896.tar.gz
dict.c: added macros in dict.h to set signed and unsigned 64 bit values directly inside the hash entry without using additional memory.
-rw-r--r--src/dict.c2
-rw-r--r--src/dict.h6
2 files changed, 7 insertions, 1 deletions
diff --git a/src/dict.c b/src/dict.c
index 11962f7c4..a573bcd6e 100644
--- a/src/dict.c
+++ b/src/dict.c
@@ -274,7 +274,7 @@ int dictAdd(dict *d, void *key, void *val)
* mainly in order to store non-pointers inside the hash value, example:
*
* entry = dictAddRaw(dict,mykey);
- * if (entry != NULL) dictSetValSignedInteger(entry,1000);
+ * if (entry != NULL) dictSetSignedIntegerVal(entry,1000);
*
* Return values:
*
diff --git a/src/dict.h b/src/dict.h
index af485e2cd..b907a91f4 100644
--- a/src/dict.h
+++ b/src/dict.h
@@ -105,6 +105,12 @@ typedef struct dictIterator {
entry->v.val = (_val_); \
} while(0)
+#define dictSetSignedIntegerVal(d, entry, _val_) \
+ do { entry->v.i64 = _val_; } while(0)
+
+#define dictSetUnsignedIntegerVal(d, entry, _val_) \
+ do { entry->v.u64 = _val_; } while(0)
+
#define dictFreeKey(d, entry) \
if ((d)->type->keyDestructor) \
(d)->type->keyDestructor((d)->privdata, (entry)->key)