]> git.saurik.com Git - redis.git/commitdiff
added dictFetchValue() to dict.c to make hash table API a bit less verbose in the...
authorantirez <antirez@gmail.com>
Fri, 16 Apr 2010 08:04:51 +0000 (10:04 +0200)
committerantirez <antirez@gmail.com>
Fri, 16 Apr 2010 08:04:51 +0000 (10:04 +0200)
dict.c
dict.h

diff --git a/dict.c b/dict.c
index 08bffbff8e44cf631c71883cd5057148f6c5cfe1..d5010708c37ce6729e3068a170e30029f2fa1d38 100644 (file)
--- a/dict.c
+++ b/dict.c
@@ -423,6 +423,13 @@ dictEntry *dictFind(dict *d, const void *key)
     return NULL;
 }
 
+void *dictFetchValue(dict *d, const void *key) {
+    dictEntry *he;
+
+    he = dictFind(d,key);
+    return he ? dictGetEntryVal(he) : NULL;
+}
+
 dictIterator *dictGetIterator(dict *d)
 {
     dictIterator *iter = _dictAlloc(sizeof(*iter));
diff --git a/dict.h b/dict.h
index ba8f86951b5dc414c6450d06abd59e9b9f7baf89..30ace4db7cba3df6bae3ac01d4a55d4f43ecc733 100644 (file)
--- a/dict.h
+++ b/dict.h
@@ -129,6 +129,7 @@ int dictDelete(dict *d, const void *key);
 int dictDeleteNoFree(dict *d, const void *key);
 void dictRelease(dict *d);
 dictEntry * dictFind(dict *d, const void *key);
+void *dictFetchValue(dict *d, const void *key);
 int dictResize(dict *d);
 dictIterator *dictGetIterator(dict *d);
 dictEntry *dictNext(dictIterator *iter);