Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-04-21 18:55:30 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-04-21 19:36:59 +0400
commit9bff19fbfd5292766671d2134a6442d5c3d7917a (patch)
treeef30d54615737d08f3a608f99500e12323b16f76 /source/blender/blenlib/intern/BLI_ghash.c
parent64b6ea032d8f1f2df75b816a2cd270da48fe1e8e (diff)
GHash, Edgehash: add lookup_default() funcs.
Returns a fallback argument when the key isn't found.
Diffstat (limited to 'source/blender/blenlib/intern/BLI_ghash.c')
-rw-r--r--source/blender/blenlib/intern/BLI_ghash.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index 1df48885637..7b48744bcdf 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -384,6 +384,16 @@ void *BLI_ghash_lookup(GHash *gh, const void *key)
}
/**
+ * A version of #BLI_ghash_lookup which accepts a fallback argument.
+ */
+void *BLI_ghash_lookup_default(GHash *gh, const void *key, void *val_default)
+{
+ Entry *e = ghash_lookup_entry(gh, key);
+ IS_GHASH_ASSERT(gh);
+ return e ? e->val : val_default;
+}
+
+/**
* Lookup a pointer to the value of \a key in \a gh.
*
* \param key The key to lookup.