From fbb446dff620c0719fd77692a0d401203ef1e966 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 18 Aug 2013 00:36:04 +0000 Subject: add assert for hashes if an existing element is ever inserted into a ghash/edgehash. the outliner does this intentionally, so add a flag to allow this situation optionally. --- source/blender/blenlib/BLI_ghash.h | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'source/blender/blenlib/BLI_ghash.h') diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h index 3ad0e18c8d7..d914c32664d 100644 --- a/source/blender/blenlib/BLI_ghash.h +++ b/source/blender/blenlib/BLI_ghash.h @@ -42,21 +42,7 @@ typedef int (*GHashCmpFP) (const void *a, const void *b); typedef void (*GHashKeyFreeFP) (void *key); typedef void (*GHashValFreeFP) (void *val); -typedef struct Entry { - struct Entry *next; - - void *key, *val; -} Entry; - -typedef struct GHash { - GHashHashFP hashfp; - GHashCmpFP cmpfp; - - Entry **buckets; - struct BLI_mempool *entrypool; - unsigned int nbuckets; - unsigned int nentries, cursize; -} GHash; +typedef struct GHash GHash; typedef struct GHashIterator { GHash *gh; @@ -64,6 +50,10 @@ typedef struct GHashIterator { struct Entry *curEntry; } GHashIterator; +enum { + GHASH_FLAG_ALLOW_DUPES = (1 << 0), /* only checked for in debug mode */ +}; + /* *** */ GHash *BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info); @@ -75,6 +65,8 @@ void BLI_ghash_clear(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfr void *BLI_ghash_pop(GHash *gh, void *key, GHashKeyFreeFP keyfreefp); bool BLI_ghash_haskey(GHash *gh, const void *key); int BLI_ghash_size(GHash *gh); +void BLI_ghash_flag_set(GHash *gh, unsigned short flag); +void BLI_ghash_flag_clear(GHash *gh, unsigned short flag); /* *** */ -- cgit v1.2.3