diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-04-21 18:55:30 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-04-21 19:36:59 +0400 |
commit | 9bff19fbfd5292766671d2134a6442d5c3d7917a (patch) | |
tree | ef30d54615737d08f3a608f99500e12323b16f76 /source/blender/blenlib/intern/BLI_ghash.c | |
parent | 64b6ea032d8f1f2df75b816a2cd270da48fe1e8e (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.c | 10 |
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. |