[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24467] trunk/blender/intern/guardedalloc: New function:

Martin Poirier theeth at yahoo.com
Tue Nov 10 22:33:53 CET 2009


Revision: 24467
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24467
Author:   theeth
Date:     2009-11-10 22:33:53 +0100 (Tue, 10 Nov 2009)

Log Message:
-----------
New function:

void MEM_callbackmemlist(void (*func)(void*));

Will call the function passed as argument with all allocated address as parameter. Useful for debuging.

Modified Paths:
--------------
    trunk/blender/intern/guardedalloc/MEM_guardedalloc.h
    trunk/blender/intern/guardedalloc/intern/mallocn.c

Modified: trunk/blender/intern/guardedalloc/MEM_guardedalloc.h
===================================================================
--- trunk/blender/intern/guardedalloc/MEM_guardedalloc.h	2009-11-10 20:50:34 UTC (rev 24466)
+++ trunk/blender/intern/guardedalloc/MEM_guardedalloc.h	2009-11-10 21:33:53 UTC (rev 24467)
@@ -102,6 +102,9 @@
 	 * blocks. */ 
 	void MEM_printmemlist(void);
 
+	/** calls the function on all allocated memory blocks. */
+	void MEM_callbackmemlist(void (*func)(void*));
+
 	/** Print statistics about memory usage */
 	void MEM_printmemlist_stats(void);
 	

Modified: trunk/blender/intern/guardedalloc/intern/mallocn.c
===================================================================
--- trunk/blender/intern/guardedalloc/intern/mallocn.c	2009-11-10 20:50:34 UTC (rev 24466)
+++ trunk/blender/intern/guardedalloc/intern/mallocn.c	2009-11-10 21:33:53 UTC (rev 24467)
@@ -460,6 +460,24 @@
 	mem_unlock_thread();
 }
 
+void MEM_callbackmemlist(void (*func)(void*)) {
+	MemHead *membl;
+
+	mem_lock_thread();
+
+	membl = membase->first;
+	if (membl) membl = MEMNEXT(membl);
+
+	while(membl) {
+		func(membl+1);
+		if(membl->next)
+			membl= MEMNEXT(membl->next);
+		else break;
+	}
+
+	mem_unlock_thread();
+}
+
 void MEM_printmemlist( void ) {
 	MEM_printmemlist_internal(0);
 }





More information about the Bf-blender-cvs mailing list