diff options
author | Martin Poirier <theeth@yahoo.com> | 2008-05-27 17:22:17 +0400 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2008-05-27 17:22:17 +0400 |
commit | e70573badd22fc08b72c7c56f39293bc70d52c71 (patch) | |
tree | a5f60f7bd9507538ec70a6534932d6b5037bbfa5 /source/blender/blenlib/intern/BLI_ghash.c | |
parent | 8676e9f44e8f5e1904bbeb12efec51a2061e656d (diff) |
gHash iterator initializer
To be able to have iterators on the stack/reuse iterators
Diffstat (limited to 'source/blender/blenlib/intern/BLI_ghash.c')
-rw-r--r-- | source/blender/blenlib/intern/BLI_ghash.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index 227cb8f5e9a..bae6ad428ea 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -198,12 +198,6 @@ void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreef /***/ -struct GHashIterator { - GHash *gh; - int curBucket; - Entry *curEntry; -}; - GHashIterator *BLI_ghashIterator_new(GHash *gh) { GHashIterator *ghi= malloc(sizeof(*ghi)); ghi->gh= gh; @@ -217,6 +211,17 @@ GHashIterator *BLI_ghashIterator_new(GHash *gh) { } return ghi; } +void BLI_ghashIterator_init(GHashIterator *ghi, GHash *gh) { + ghi->gh= gh; + ghi->curEntry= NULL; + ghi->curBucket= -1; + while (!ghi->curEntry) { + ghi->curBucket++; + if (ghi->curBucket==ghi->gh->nbuckets) + break; + ghi->curEntry= ghi->gh->buckets[ghi->curBucket]; + } +} void BLI_ghashIterator_free(GHashIterator *ghi) { free(ghi); } |