From d59b4752e432aa1188fe9082a99d3aa6f6d59ab1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Sep 2013 02:58:53 +0000 Subject: [PATCH] add hash iterator functions to access the pointer to the value. --- source/blender/blenlib/BLI_edgehash.h | 1 + source/blender/blenlib/BLI_ghash.h | 1 + source/blender/blenlib/intern/BLI_ghash.c | 12 ++++++++++++ source/blender/blenlib/intern/edgehash.c | 8 ++++++++ 4 files changed, 22 insertions(+) diff --git a/source/blender/blenlib/BLI_edgehash.h b/source/blender/blenlib/BLI_edgehash.h index 5a5ea5ca3be..510d881f26d 100644 --- a/source/blender/blenlib/BLI_edgehash.h +++ b/source/blender/blenlib/BLI_edgehash.h @@ -62,6 +62,7 @@ EdgeHashIterator *BLI_edgehashIterator_new(EdgeHash *eh) ATTR_MALLOC ATTR_WARN void BLI_edgehashIterator_free(EdgeHashIterator *ehi); void BLI_edgehashIterator_getKey(EdgeHashIterator *ehi, unsigned int *v0_r, unsigned int *v1_r); void *BLI_edgehashIterator_getValue(EdgeHashIterator *ehi) ATTR_WARN_UNUSED_RESULT; +void **BLI_edgehashIterator_getValue_p(EdgeHashIterator *ehi) ATTR_WARN_UNUSED_RESULT; void BLI_edgehashIterator_setValue(EdgeHashIterator *ehi, void *val); void BLI_edgehashIterator_step(EdgeHashIterator *ehi); bool BLI_edgehashIterator_isDone(EdgeHashIterator *ehi) ATTR_WARN_UNUSED_RESULT; diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h index 17ad47aa871..e5a93691ad0 100644 --- a/source/blender/blenlib/BLI_ghash.h +++ b/source/blender/blenlib/BLI_ghash.h @@ -86,6 +86,7 @@ void BLI_ghashIterator_free(GHashIterator *ghi); void *BLI_ghashIterator_getKey(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT; void *BLI_ghashIterator_getValue(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT; +void **BLI_ghashIterator_getValue_p(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT; void BLI_ghashIterator_step(GHashIterator *ghi); bool BLI_ghashIterator_done(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT; diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index 750202c509d..7b50e9012a8 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -601,6 +601,18 @@ void *BLI_ghashIterator_getValue(GHashIterator *ghi) return ghi->curEntry ? ghi->curEntry->val : NULL; } +/** + * Retrieve the value from an iterator. + * + * \param ghi The iterator. + * \return The value at the current index, or NULL if the + * iterator is done. + */ +void **BLI_ghashIterator_getValue_p(GHashIterator *ghi) +{ + return ghi->curEntry ? &ghi->curEntry->val : NULL; +} + /** * Steps the iterator to the next index. * diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c index 967b59cf25d..b26e007b3e6 100644 --- a/source/blender/blenlib/intern/edgehash.c +++ b/source/blender/blenlib/intern/edgehash.c @@ -483,6 +483,14 @@ void *BLI_edgehashIterator_getValue(EdgeHashIterator *ehi) return ehi->curEntry ? ehi->curEntry->val : NULL; } +/** + * Retrieve the pointer to the value from an iterator. + */ +void **BLI_edgehashIterator_getValue_p(EdgeHashIterator *ehi) +{ + return ehi->curEntry ? &ehi->curEntry->val : NULL; +} + /** * Set the value for an iterator. */