[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28576] branches/render25: pass string to new hashes as with guarded alloc and memarena, this way theres no need to use a compile time option

Campbell Barton ideasman42 at gmail.com
Tue May 4 17:36:12 CEST 2010


Revision: 28576
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28576
Author:   campbellbarton
Date:     2010-05-04 17:36:11 +0200 (Tue, 04 May 2010)

Log Message:
-----------
pass string to new hashes as with guarded alloc and memarena, this way theres no need to use a compile time option

Modified Paths:
--------------
    branches/render25/CMakeLists.txt
    branches/render25/source/blender/blenkernel/intern/BME_tools.c
    branches/render25/source/blender/blenkernel/intern/action.c
    branches/render25/source/blender/blenkernel/intern/cloth.c
    branches/render25/source/blender/blenkernel/intern/depsgraph.c
    branches/render25/source/blender/blenkernel/intern/icons.c
    branches/render25/source/blender/blenkernel/intern/nla.c
    branches/render25/source/blender/blenkernel/intern/softbody.c
    branches/render25/source/blender/blenlib/BLI_ghash.h
    branches/render25/source/blender/blenlib/intern/BLI_args.c
    branches/render25/source/blender/blenlib/intern/BLI_ghash.c
    branches/render25/source/blender/blenlib/intern/pbvh.c
    branches/render25/source/blender/blenloader/intern/readblenentry.c
    branches/render25/source/blender/editors/armature/editarmature.c
    branches/render25/source/blender/editors/armature/editarmature_retarget.c
    branches/render25/source/blender/editors/armature/editarmature_sketch.c
    branches/render25/source/blender/editors/armature/reeb.c
    branches/render25/source/blender/editors/mesh/editmesh_loop.c
    branches/render25/source/blender/editors/mesh/editmesh_tools.c
    branches/render25/source/blender/editors/mesh/meshtools.c
    branches/render25/source/blender/editors/sculpt_paint/paint_vertex.c
    branches/render25/source/blender/editors/transform/transform.c
    branches/render25/source/blender/gpu/intern/gpu_codegen.c
    branches/render25/source/blender/imbuf/intern/cache.c
    branches/render25/source/blender/makesrna/intern/rna_access.c
    branches/render25/source/blender/modifiers/intern/MOD_boolean_util.c
    branches/render25/source/blender/modifiers/intern/MOD_build.c
    branches/render25/source/blender/modifiers/intern/MOD_mask.c
    branches/render25/source/blender/render/intern/source/cache.c
    branches/render25/source/blender/render/intern/source/database.c
    branches/render25/source/blender/render/intern/source/object_strand.c
    branches/render25/source/blender/render/intern/source/object_subdivide.c
    branches/render25/source/blender/render/intern/source/sss.c
    branches/render25/source/gameengine/Converter/BL_ArmatureObject.cpp

Modified: branches/render25/CMakeLists.txt
===================================================================
--- branches/render25/CMakeLists.txt	2010-05-04 15:14:17 UTC (rev 28575)
+++ branches/render25/CMakeLists.txt	2010-05-04 15:36:11 UTC (rev 28576)
@@ -80,7 +80,6 @@
 OPTION(WITH_BUILDINFO     "Include extra build details" ON)
 OPTION(WITH_INSTALL       "Install accompanying scripts and language files needed to run blender" ON)
 OPTION(WITH_OPENCOLLADA		"Enable OpenCollada Support (http://www.opencollada.org/)"	ON)
-OPTION(WITH_DEBUG_GHASH   "Append extra info to ghash memory blocks, to help track down memory leaks" OFF)
 
 # Unix defaults to OpenMP On
 IF(UNIX AND NOT APPLE)
@@ -668,12 +667,6 @@
 	SET(CMAKE_CXX_FLAGS " -DWITH_CXX_GUARDEDALLOC -I${CMAKE_SOURCE_DIR}/intern/guardedalloc ${CMAKE_CXX_FLAGS}")
 ENDIF(WITH_CXX_GUARDEDALLOC)
 
-#ghash debug mode
-IF(WITH_DEBUG_GHASH)
-    SET(CMAKE_CXX_FLAGS " -DGHASH_DEBUG_LEAKS ${CMAKE_CXX_FLAGS}")
-    SET(CMAKE_C_FLAGS " -DGHASH_DEBUG_LEAKS ${CMAKE_C_FLAGS}")
-ENDIF(WITH_DEBUG_GHASH)
-
 #-----------------------------------------------------------------------------
 # Libraries
 FILE(WRITE ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt "")

Modified: branches/render25/source/blender/blenkernel/intern/BME_tools.c
===================================================================
--- branches/render25/source/blender/blenkernel/intern/BME_tools.c	2010-05-04 15:14:17 UTC (rev 28575)
+++ branches/render25/source/blender/blenkernel/intern/BME_tools.c	2010-05-04 15:36:11 UTC (rev 28576)
@@ -49,7 +49,7 @@
 	BME_TransData_Head *td;
 
 	td = MEM_callocN(sizeof(BME_TransData_Head), "BMesh transdata header");
-	td->gh = BLI_ghash_new(BLI_ghashutil_ptrhash,BLI_ghashutil_ptrcmp);
+	td->gh = BLI_ghash_new(BLI_ghashutil_ptrhash,BLI_ghashutil_ptrcmp, "BME_init_transdata gh");
 	td->ma = BLI_memarena_new(bufsize, "BME_TransData arena");
 	BLI_memarena_use_calloc(td->ma);
 

Modified: branches/render25/source/blender/blenkernel/intern/action.c
===================================================================
--- branches/render25/source/blender/blenkernel/intern/action.c	2010-05-04 15:14:17 UTC (rev 28575)
+++ branches/render25/source/blender/blenkernel/intern/action.c	2010-05-04 15:36:11 UTC (rev 28576)
@@ -549,7 +549,7 @@
 	if(!pose->chanhash) {
 		bPoseChannel *pchan;
 
-		pose->chanhash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp);
+		pose->chanhash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "make_pose_chan gh");
 		for(pchan=pose->chanbase.first; pchan; pchan=pchan->next)
 			BLI_ghash_insert(pose->chanhash, pchan->name, pchan);
 	}

Modified: branches/render25/source/blender/blenkernel/intern/cloth.c
===================================================================
--- branches/render25/source/blender/blenkernel/intern/cloth.c	2010-05-04 15:14:17 UTC (rev 28575)
+++ branches/render25/source/blender/blenkernel/intern/cloth.c	2010-05-04 15:36:11 UTC (rev 28576)
@@ -220,7 +220,7 @@
 	bvhtree = BLI_bvhtree_new(cloth->numfaces, epsilon, 4, 26);
 	
 	// fill tree
-	gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
+	gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "build_from_cloth gh");
 	for(i = 0; i < cloth->numfaces; i++, mfaces++)
 	{
 		BLI_ghash_insert(gh, &verts[mfaces->v1], NULL);

Modified: branches/render25/source/blender/blenkernel/intern/depsgraph.c
===================================================================
--- branches/render25/source/blender/blenkernel/intern/depsgraph.c	2010-05-04 15:14:17 UTC (rev 28575)
+++ branches/render25/source/blender/blenkernel/intern/depsgraph.c	2010-05-04 15:36:11 UTC (rev 28576)
@@ -803,7 +803,7 @@
 		}
 
 		if(!forest->nodeHash)
-			forest->nodeHash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
+			forest->nodeHash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "dag_add_node gh");
 		BLI_ghash_insert(forest->nodeHash, fob, node);
 	}
 

Modified: branches/render25/source/blender/blenkernel/intern/icons.c
===================================================================
--- branches/render25/source/blender/blenkernel/intern/icons.c	2010-05-04 15:14:17 UTC (rev 28575)
+++ branches/render25/source/blender/blenkernel/intern/icons.c	2010-05-04 15:36:11 UTC (rev 28576)
@@ -101,7 +101,7 @@
 	gFirstIconId = first_dyn_id;
 
 	if (!gIcons)
-		gIcons = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp);
+		gIcons = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "icons_init gh");
 }
 
 void BKE_icons_free()

Modified: branches/render25/source/blender/blenkernel/intern/nla.c
===================================================================
--- branches/render25/source/blender/blenkernel/intern/nla.c	2010-05-04 15:14:17 UTC (rev 28575)
+++ branches/render25/source/blender/blenkernel/intern/nla.c	2010-05-04 15:36:11 UTC (rev 28576)
@@ -1243,7 +1243,7 @@
 	 *	- this is easier than iterating over all the tracks+strips hierarchy everytime
 	 *	  (and probably faster)
 	 */
-	gh= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp);
+	gh= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "nlastrip_validate_name gh");
 	
 	for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) {
 		for (tstrip= nlt->strips.first; tstrip; tstrip= tstrip->next) {

Modified: branches/render25/source/blender/blenkernel/intern/softbody.c
===================================================================
--- branches/render25/source/blender/blenkernel/intern/softbody.c	2010-05-04 15:14:17 UTC (rev 28575)
+++ branches/render25/source/blender/blenkernel/intern/softbody.c	2010-05-04 15:36:11 UTC (rev 28576)
@@ -3663,7 +3663,7 @@
 {
 	if (!sb) return;
 	sb->scratch = MEM_callocN(sizeof(SBScratch), "SBScratch");
-	sb->scratch->colliderhash = BLI_ghash_new(BLI_ghashutil_ptrhash,BLI_ghashutil_ptrcmp);
+	sb->scratch->colliderhash = BLI_ghash_new(BLI_ghashutil_ptrhash,BLI_ghashutil_ptrcmp, "sb_new_scratch gh");
 	sb->scratch->bodyface = NULL;
 	sb->scratch->totface = 0;
 	sb->scratch->aabbmax[0]=sb->scratch->aabbmax[1]=sb->scratch->aabbmax[2] = 1.0e30f;

Modified: branches/render25/source/blender/blenlib/BLI_ghash.h
===================================================================
--- branches/render25/source/blender/blenlib/BLI_ghash.h	2010-05-04 15:14:17 UTC (rev 28575)
+++ branches/render25/source/blender/blenlib/BLI_ghash.h	2010-05-04 15:36:11 UTC (rev 28576)
@@ -63,9 +63,6 @@
 	
 	Entry **buckets;
 	struct BLI_mempool *entrypool;
-#ifdef GHASH_DEBUG_LEAKS
-	const char *tag;
-#endif
 	int nbuckets, nentries, cursize;
 } GHash;
 
@@ -75,12 +72,7 @@
 	struct Entry *curEntry;
 } GHashIterator;
 
-#ifndef GHASH_DEBUG_LEAKS
-	GHash*	BLI_ghash_new		(GHashHashFP hashfp, GHashCmpFP cmpfp);
-#else
-	GHash *_BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, char *file, int line);
-	#define BLI_ghash_new(hashfp, cmpfp) _BLI_ghash_new(hashfp, cmpfp, __FILE__, __LINE__)
-#endif
+GHash*	BLI_ghash_new		(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info);
 void	BLI_ghash_free		(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp);
 
 //BM_INLINE void	BLI_ghash_insert	(GHash *gh, void *key, void *val);

Modified: branches/render25/source/blender/blenlib/intern/BLI_args.c
===================================================================
--- branches/render25/source/blender/blenlib/intern/BLI_args.c	2010-05-04 15:14:17 UTC (rev 28575)
+++ branches/render25/source/blender/blenlib/intern/BLI_args.c	2010-05-04 15:36:11 UTC (rev 28576)
@@ -102,7 +102,7 @@
 {
 	bArgs *ba = MEM_callocN(sizeof(bArgs), "bArgs");
 	ba->passes = MEM_callocN(sizeof(int) * argc, "bArgs passes");
-	ba->items = BLI_ghash_new(keyhash, keycmp);
+	ba->items = BLI_ghash_new(keyhash, keycmp, "bArgs passes gh");
 	ba->argc = argc;
 	ba->argv = argv;
 

Modified: branches/render25/source/blender/blenlib/intern/BLI_ghash.c
===================================================================
--- branches/render25/source/blender/blenlib/intern/BLI_ghash.c	2010-05-04 15:14:17 UTC (rev 28575)
+++ branches/render25/source/blender/blenlib/intern/BLI_ghash.c	2010-05-04 15:36:11 UTC (rev 28576)
@@ -45,20 +45,8 @@
 
 /***/
 
-#ifdef GHASH_DEBUG_LEAKS
-GHash *_BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, char *file, int line) {
-	const char *str = calloc(1, strlen(file) + 32);
-	GHash *gh;
-
-	sprintf(str, "GHash@%s:%d", file, line);
-
-	gh = MEM_mallocN(sizeof(*gh), str);
-	gh->tag = str;
-
-#else
-GHash *BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp) {
-	GHash *gh= MEM_mallocN(sizeof(*gh), "GHash");
-#endif
+GHash *BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info) {
+	GHash *gh= MEM_mallocN(sizeof(*gh), info);
 	gh->hashfp= hashfp;
 	gh->cmpfp= cmpfp;
 	gh->entrypool = BLI_mempool_create(sizeof(Entry), 64, 64, 0);
@@ -105,10 +93,6 @@
 	gh->nentries = 0;
 	gh->nbuckets = 0;
 	MEM_freeN(gh);
-
-#ifdef GHASH_DEBUG_LEAKS
-	free(gh->tag);
-#endif
 }
 
 /***/

Modified: branches/render25/source/blender/blenlib/intern/pbvh.c
===================================================================
--- branches/render25/source/blender/blenlib/intern/pbvh.c	2010-05-04 15:14:17 UTC (rev 28575)
+++ branches/render25/source/blender/blenlib/intern/pbvh.c	2010-05-04 15:36:11 UTC (rev 28576)
@@ -303,7 +303,7 @@
 	GHash *map;
 	int i, j, totface;
 
-	map = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp);
+	map = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "build_mesh_leaf_node gh");
 	
 	node->uniq_verts = node->face_verts = 0;
 	totface= node->totprim;
@@ -970,7 +970,7 @@
 	void *face, **faces;
 	int i, tot;
 
-	map = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
+	map = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "pbvh_get_grid_updates gh");
 
 	pbvh_iter_begin(&iter, bvh, NULL, NULL);
 

Modified: branches/render25/source/blender/blenloader/intern/readblenentry.c
===================================================================
--- branches/render25/source/blender/blenloader/intern/readblenentry.c	2010-05-04 15:14:17 UTC (rev 28575)
+++ branches/render25/source/blender/blenloader/intern/readblenentry.c	2010-05-04 15:36:11 UTC (rev 28576)
@@ -283,7 +283,7 @@
 LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh) 
 {
 	FileData *fd= (FileData*) bh;
-	GHash *gathered= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list