Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--release/datafiles/prvicons.pngbin15971 -> 15991 bytes
-rw-r--r--source/blender/blenlib/intern/BLI_ghash.c24
-rw-r--r--source/blender/blenlib/intern/edgehash.c25
3 files changed, 42 insertions, 7 deletions
diff --git a/release/datafiles/prvicons.png b/release/datafiles/prvicons.png
index cf8833c3362..f8f744aadb3 100644
--- a/release/datafiles/prvicons.png
+++ b/release/datafiles/prvicons.png
Binary files differ
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index 2adc24b657c..5462a61d967 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -61,6 +61,16 @@ const unsigned int hashsizes[] = {
268435459
};
+/* internal flag to ensure sets values aren't used */
+#ifndef NDEBUG
+# define GHASH_FLAG_IS_SET (1 << 8)
+# define IS_GHASH_ASSERT(gh) BLI_assert((gh->flag & GHASH_FLAG_IS_SET) == 0)
+// # define IS_GSET_ASSERT(gs) BLI_assert((gs->flag & GHASH_FLAG_IS_SET) != 0)
+#else
+# define IS_GHASH_ASSERT(gh)
+// # define IS_GSET_ASSERT(eh)
+#endif
+
/***/
typedef struct Entry {
@@ -346,6 +356,7 @@ bool BLI_ghash_reinsert(GHash *gh, void *key, void *val, GHashKeyFreeFP keyfreef
void *BLI_ghash_lookup(GHash *gh, const void *key)
{
Entry *e = ghash_lookup_entry(gh, key);
+ IS_GHASH_ASSERT(gh);
return e ? e->val : NULL;
}
@@ -362,6 +373,7 @@ void *BLI_ghash_lookup(GHash *gh, const void *key)
void **BLI_ghash_lookup_p(GHash *gh, const void *key)
{
Entry *e = ghash_lookup_entry(gh, key);
+ IS_GHASH_ASSERT(gh);
return e ? &e->val : NULL;
}
@@ -399,6 +411,7 @@ void *BLI_ghash_pop(GHash *gh, void *key, GHashKeyFreeFP keyfreefp)
{
const unsigned int hash = ghash_keyhash(gh, key);
Entry *e = ghash_remove_ex(gh, key, keyfreefp, NULL, hash);
+ IS_GHASH_ASSERT(gh);
if (e) {
void *val = e->val;
BLI_mempool_free(gh->entrypool, e);
@@ -462,7 +475,6 @@ void BLI_ghash_clear(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfree
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
{
BLI_assert((int)gh->nentries == BLI_mempool_count(gh->entrypool));
-
if (keyfreefp || valfreefp)
ghash_free_cb(gh, keyfreefp, valfreefp);
@@ -773,9 +785,13 @@ GHash *BLI_ghash_pair_new(const char *info)
GSet *BLI_gset_new_ex(GSetHashFP hashfp, GSetCmpFP cmpfp, const char *info,
const unsigned int nentries_reserve)
{
- return (GSet *)ghash_new(hashfp, cmpfp, info,
- nentries_reserve,
- sizeof(Entry) - sizeof(void *));
+ GSet *gs = (GSet *)ghash_new(hashfp, cmpfp, info,
+ nentries_reserve,
+ sizeof(Entry) - sizeof(void *));
+#ifndef NDEBUG
+ ((GHash *)gs)->flag |= GHASH_FLAG_IS_SET;
+#endif
+ return gs;
}
GSet *BLI_gset_new(GSetHashFP hashfp, GSetCmpFP cmpfp, const char *info)
diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c
index 8870bce435b..03822e894cf 100644
--- a/source/blender/blenlib/intern/edgehash.c
+++ b/source/blender/blenlib/intern/edgehash.c
@@ -55,6 +55,16 @@ static const unsigned int _ehash_hashsizes[] = {
268435459
};
+/* internal flag to ensure sets values aren't used */
+#ifndef NDEBUG
+# define EDGEHASH_FLAG_IS_SET (1 << 8)
+# define IS_EDGEHASH_ASSERT(eh) BLI_assert((eh->flag & EDGEHASH_FLAG_IS_SET) == 0)
+// # define IS_EDGESET_ASSERT(es) BLI_assert((es->flag & EDGEHASH_FLAG_IS_SET) != 0)
+#else
+# define IS_EDGEHASH_ASSERT(eh)
+// # define IS_EDGESET_ASSERT(es)
+#endif
+
/* ensure v0 is smaller */
#define EDGE_ORD(v0, v1) \
if (v0 > v1) { \
@@ -242,6 +252,7 @@ void BLI_edgehash_insert(EdgeHash *eh, unsigned int v0, unsigned int v1, void *v
{
unsigned int hash;
EdgeEntry *e;
+ IS_EDGEHASH_ASSERT(eh);
EDGE_ORD(v0, v1); /* ensure v0 is smaller */
hash = edgehash_keyhash(eh, v0, v1);
e = edgehash_insert_ex(eh, v0, v1, hash);
@@ -256,6 +267,8 @@ bool BLI_edgehash_reinsert(EdgeHash *eh, unsigned int v0, unsigned int v1, void
unsigned int hash;
EdgeEntry *e;
+ IS_EDGEHASH_ASSERT(eh);
+
EDGE_ORD(v0, v1); /* ensure v0 is smaller */
hash = edgehash_keyhash(eh, v0, v1);
@@ -278,6 +291,7 @@ bool BLI_edgehash_reinsert(EdgeHash *eh, unsigned int v0, unsigned int v1, void
void **BLI_edgehash_lookup_p(EdgeHash *eh, unsigned int v0, unsigned int v1)
{
EdgeEntry *e = edgehash_lookup_entry(eh, v0, v1);
+ IS_EDGEHASH_ASSERT(eh);
return e ? &e->val : NULL;
}
@@ -290,6 +304,7 @@ void **BLI_edgehash_lookup_p(EdgeHash *eh, unsigned int v0, unsigned int v1)
void *BLI_edgehash_lookup(EdgeHash *eh, unsigned int v0, unsigned int v1)
{
EdgeEntry *e = edgehash_lookup_entry(eh, v0, v1);
+ IS_EDGEHASH_ASSERT(eh);
return e ? e->val : NULL;
}
@@ -467,9 +482,13 @@ bool BLI_edgehashIterator_isDone(EdgeHashIterator *ehi)
EdgeSet *BLI_edgeset_new_ex(const char *info,
const unsigned int nentries_reserve)
{
- return (EdgeSet *)edgehash_new(info,
- nentries_reserve,
- sizeof(EdgeEntry) - sizeof(void *));
+ EdgeSet *es = (EdgeSet *)edgehash_new(info,
+ nentries_reserve,
+ sizeof(EdgeEntry) - sizeof(void *));
+#ifndef NDEBUG
+ ((EdgeHash *)es)->flag |= EDGEHASH_FLAG_IS_SET;
+#endif
+ return es;
}
EdgeSet *BLI_edgeset_new(const char *info)