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
path: root/intern
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2008-01-03 17:53:44 +0300
committerCampbell Barton <ideasman42@gmail.com>2008-01-03 17:53:44 +0300
commit86471f8b72d2a6ac8f6078b92f701da1eeab2525 (patch)
treeec023f4f7c9fbcd3a5c1809210f8a713934bfea7 /intern
parent0e716733bceda96d298540cadf2ed18169d9cb52 (diff)
Split guardedalloc print into 2 funcs, 1 that prints on errors, another then prints the memory blocks as a python dict, minor changes to help text
Diffstat (limited to 'intern')
-rw-r--r--intern/guardedalloc/MEM_guardedalloc.h6
-rw-r--r--intern/guardedalloc/intern/mallocn.c29
2 files changed, 27 insertions, 8 deletions
diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h
index 26a9258d03b..94276c0454a 100644
--- a/intern/guardedalloc/MEM_guardedalloc.h
+++ b/intern/guardedalloc/MEM_guardedalloc.h
@@ -100,9 +100,13 @@ extern "C" {
void *MEM_mapallocN(unsigned int len, const char * str);
/** Print a list of the names and sizes of all allocated memory
+ * blocks. as a python dict for easy investigation */
+ void MEM_printmemlist_pydict(void);
+
+ /** Print a list of the names and sizes of all allocated memory
* blocks. */
void MEM_printmemlist(void);
-
+
/** Set the callback function for error output. */
void MEM_set_error_callback(void (*func)(char *));
diff --git a/intern/guardedalloc/intern/mallocn.c b/intern/guardedalloc/intern/mallocn.c
index 44909bbea54..413f4d80514 100644
--- a/intern/guardedalloc/intern/mallocn.c
+++ b/intern/guardedalloc/intern/mallocn.c
@@ -334,7 +334,7 @@ void *MEM_mapallocN(unsigned int len, const char *str)
/* Prints in python syntax for easy */
-void MEM_printmemlist()
+static void MEM_printmemlist_internal( int pydict )
{
MemHead *membl;
@@ -343,16 +343,23 @@ void MEM_printmemlist()
membl = membase->first;
if (membl) membl = MEMNEXT(membl);
- print_error("# membase_debug.py\n");
- print_error("membase = [\\\n");
+ if (pydict) {
+ print_error("# membase_debug.py\n");
+ print_error("membase = [\\\n");
+ }
while(membl) {
- fprintf(stderr, "{'len':%i, 'name':'''%s''', 'pointer':'%p'},\\\n", membl->len, membl->name, membl+1);
+ if (pydict) {
+ fprintf(stderr, "{'len':%i, 'name':'''%s''', 'pointer':'%p'},\\\n", membl->len, membl->name, membl+1);
+ } else {
+ print_error("%s len: %d %p\n",membl->name,membl->len, membl+1);
+ }
if(membl->next)
membl= MEMNEXT(membl->next);
else break;
}
- fprintf(stderr, "]\n\n");
- fprintf(stderr,
+ if (pydict) {
+ fprintf(stderr, "]\n\n");
+ fprintf(stderr,
"mb_userinfo = {}\n"
"totmem = 0\n"
"for mb_item in membase:\n"
@@ -367,11 +374,19 @@ void MEM_printmemlist()
"\tmb_userinfo_sort.sort(key = sort_func)\n"
"\tfor item in mb_userinfo_sort:\n"
"\t\tprint 'name:%%s, users:%%i, len:%%i' %% (item[0], item[1][0], item[1][1])\n"
- );
+ );
+ }
mem_unlock_thread();
}
+void MEM_printmemlist( void ) {
+ MEM_printmemlist_internal(0);
+}
+void MEM_printmemlist_pydict( void ) {
+ MEM_printmemlist_internal(1);
+}
+
short MEM_freeN(void *vmemh) /* anders compileertie niet meer */
{
short error = 0;