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.
This commit is contained in:
@@ -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);
|
||||
|
||||
/* *** */
|
||||
|
||||
|
Reference in New Issue
Block a user