[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24471] trunk/blender/intern/guardedalloc: Debug tools: new function MEM_testN(void*)
Martin Poirier
theeth at yahoo.com
Wed Nov 11 04:45:28 CET 2009
Revision: 24471
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24471
Author: theeth
Date: 2009-11-11 04:45:26 +0100 (Wed, 11 Nov 2009)
Log Message:
-----------
Debug tools: new function MEM_testN(void*)
returns 0 if pointer is not in memlist
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-11 02:15:09 UTC (rev 24470)
+++ trunk/blender/intern/guardedalloc/MEM_guardedalloc.h 2009-11-11 03:45:26 UTC (rev 24471)
@@ -73,7 +73,13 @@
*/
short MEM_freeN(void *vmemh);
+
/**
+ * Return zero if memory is not in allocated list
+ */
+ short MEM_testN(void *vmemh);
+
+ /**
* Duplicates a block of memory, and returns a pointer to the
* newly allocated block. */
void *MEM_dupallocN(void *vmemh);
Modified: trunk/blender/intern/guardedalloc/intern/mallocn.c
===================================================================
--- trunk/blender/intern/guardedalloc/intern/mallocn.c 2009-11-11 02:15:09 UTC (rev 24470)
+++ trunk/blender/intern/guardedalloc/intern/mallocn.c 2009-11-11 03:45:26 UTC (rev 24471)
@@ -478,6 +478,29 @@
mem_unlock_thread();
}
+short MEM_testN(void *vmemh) {
+ MemHead *membl;
+
+ mem_lock_thread();
+
+ membl = membase->first;
+ if (membl) membl = MEMNEXT(membl);
+
+ while(membl) {
+ if (vmemh == membl+1)
+ return 1;
+
+ if(membl->next)
+ membl= MEMNEXT(membl->next);
+ else break;
+ }
+
+ mem_unlock_thread();
+
+ print_error("Memoryblock %p: pointer not in memlist\n", vmemh);
+ return 0;
+}
+
void MEM_printmemlist( void ) {
MEM_printmemlist_internal(0);
}
@@ -518,7 +541,6 @@
}
mem_lock_thread();
-
if ((memh->tag1 == MEMTAG1) && (memh->tag2 == MEMTAG2) && ((memh->len & 0x3) == 0)) {
memt = (MemTail *)(((char *) memh) + sizeof(MemHead) + memh->len);
if (memt->tag3 == MEMTAG3){
More information about the Bf-blender-cvs
mailing list