Commit to prvicons.png was accidental, not sure its good to auto-generate, overwriting whats in svn.
On Mon, Aug 26, 2013 at 7:37 PM, Campbell Barton <[email protected]> wrote: > Revision: 59510 > > http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59510 > Author: campbellbarton > Date: 2013-08-26 09:37:15 +0000 (Mon, 26 Aug 2013) > Log Message: > ----------- > add some safety checks in debug mode to ensure sets/hashes aren't confused. > > Modified Paths: > -------------- > trunk/blender/release/datafiles/prvicons.png > trunk/blender/source/blender/blenlib/intern/BLI_ghash.c > trunk/blender/source/blender/blenlib/intern/edgehash.c > > Modified: trunk/blender/release/datafiles/prvicons.png > =================================================================== > (Binary files differ) > > Modified: trunk/blender/source/blender/blenlib/intern/BLI_ghash.c > =================================================================== > --- trunk/blender/source/blender/blenlib/intern/BLI_ghash.c 2013-08-26 > 08:14:52 UTC (rev 59509) > +++ trunk/blender/source/blender/blenlib/intern/BLI_ghash.c 2013-08-26 > 09:37:15 UTC (rev 59510) > @@ -61,6 +61,16 @@ > 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 @@ > 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_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 @@ > { > 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_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 @@ > 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) > > Modified: trunk/blender/source/blender/blenlib/intern/edgehash.c > =================================================================== > --- trunk/blender/source/blender/blenlib/intern/edgehash.c 2013-08-26 > 08:14:52 UTC (rev 59509) > +++ trunk/blender/source/blender/blenlib/intern/edgehash.c 2013-08-26 > 09:37:15 UTC (rev 59510) > @@ -55,6 +55,16 @@ > 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 @@ > { > 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 @@ > 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 @@ > 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(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 @@ > 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) > > _______________________________________________ > Bf-blender-cvs mailing list > [email protected] > http://lists.blender.org/mailman/listinfo/bf-blender-cvs -- - Campbell _______________________________________________ Bf-blender-cvs mailing list [email protected] http://lists.blender.org/mailman/listinfo/bf-blender-cvs
