mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
dict.c: added macros in dict.h to set signed and unsigned 64 bit values directly inside the hash entry without using additional memory.
This commit is contained in:
parent
c0ba9ebe13
commit
aa9a61ccd7
@ -274,7 +274,7 @@ int dictAdd(dict *d, void *key, void *val)
|
|||||||
* mainly in order to store non-pointers inside the hash value, example:
|
* mainly in order to store non-pointers inside the hash value, example:
|
||||||
*
|
*
|
||||||
* entry = dictAddRaw(dict,mykey);
|
* entry = dictAddRaw(dict,mykey);
|
||||||
* if (entry != NULL) dictSetValSignedInteger(entry,1000);
|
* if (entry != NULL) dictSetSignedIntegerVal(entry,1000);
|
||||||
*
|
*
|
||||||
* Return values:
|
* Return values:
|
||||||
*
|
*
|
||||||
|
@ -105,6 +105,12 @@ typedef struct dictIterator {
|
|||||||
entry->v.val = (_val_); \
|
entry->v.val = (_val_); \
|
||||||
} while(0)
|
} 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) \
|
#define dictFreeKey(d, entry) \
|
||||||
if ((d)->type->keyDestructor) \
|
if ((d)->type->keyDestructor) \
|
||||||
(d)->type->keyDestructor((d)->privdata, (entry)->key)
|
(d)->type->keyDestructor((d)->privdata, (entry)->key)
|
||||||
|
Loading…
Reference in New Issue
Block a user