diff options
| author | Chris Apers | 2006-09-17 09:46:06 +0000 | 
|---|---|---|
| committer | Chris Apers | 2006-09-17 09:46:06 +0000 | 
| commit | 42dd017faf6a34ad7747c9d4ab4985576aa50546 (patch) | |
| tree | 7e95c53cd1778d2f5f166e422f8844e81311a665 /backends/platform/PalmOS/Src | |
| parent | 24f55e47e16c0660616cb9cb0bc8d0f0fd11f445 (diff) | |
| download | scummvm-rg350-42dd017faf6a34ad7747c9d4ab4985576aa50546.tar.gz scummvm-rg350-42dd017faf6a34ad7747c9d4ab4985576aa50546.tar.bz2 scummvm-rg350-42dd017faf6a34ad7747c9d4ab4985576aa50546.zip  | |
Added option to trace memory allocation
svn-id: r23904
Diffstat (limited to 'backends/platform/PalmOS/Src')
| -rw-r--r-- | backends/platform/PalmOS/Src/missing/ext_stdlib.c | 24 | ||||
| -rw-r--r-- | backends/platform/PalmOS/Src/missing/stdlib.h | 13 | 
2 files changed, 32 insertions, 5 deletions
diff --git a/backends/platform/PalmOS/Src/missing/ext_stdlib.c b/backends/platform/PalmOS/Src/missing/ext_stdlib.c index 8c8fbd50bd..701e3bca69 100644 --- a/backends/platform/PalmOS/Src/missing/ext_stdlib.c +++ b/backends/platform/PalmOS/Src/missing/ext_stdlib.c @@ -24,6 +24,10 @@  #include <stdlib.h> +#ifdef STDLIB_TRACE_MEMORY +UInt32 __stdlib_trace_memory = 0; +#endif +  #define memNewChunkFlagAllowLarge	0x1000   SysAppInfoPtr SysGetAppInfo(SysAppInfoPtr *uiAppPP, SysAppInfoPtr *actionCodeAppPP) SYS_TRAP(sysTrapSysGetAppInfo); @@ -60,6 +64,9 @@ MemPtr __malloc(UInt32 size) {  		newP = MemChunkNew(0, size, attr);  	} +#ifdef STDLIB_TRACE_MEMORY +	__stdlib_trace_memory += size; +#endif  	return newP;  } @@ -72,18 +79,33 @@ MemPtr calloc(UInt32 nelem, UInt32 elsize) {  	if (newP)  		MemSet(newP,size,0); +#ifdef STDLIB_TRACE_MEMORY +	__stdlib_trace_memory += size; +#endif  	return newP;  }  Err free(MemPtr memP) { -	if (memP) +	if (memP) { +#ifdef STDLIB_TRACE_MEMORY +		UInt32 sz = MemPtrSize(memP); +		__stdlib_trace_memory -= sz; +#endif  		return MemPtrFree(memP); +	} +  	return memErrInvalidParam;  }  MemPtr realloc(MemPtr oldP, UInt32 size) {  	MemPtr newP; +#ifdef STDLIB_TRACE_MEMORY +	UInt32 sz = MemPtrSize(oldP); +	__stdlib_trace_memory -= sz; +	__stdlib_trace_memory += size; +#endif +  	if (oldP != NULL)  		if (MemPtrResize(oldP, size) == 0)  			return oldP; diff --git a/backends/platform/PalmOS/Src/missing/stdlib.h b/backends/platform/PalmOS/Src/missing/stdlib.h index 8b1c959c01..95e65b3232 100644 --- a/backends/platform/PalmOS/Src/missing/stdlib.h +++ b/backends/platform/PalmOS/Src/missing/stdlib.h @@ -36,12 +36,17 @@ extern "C" {  #endif  /* malloc stuff */ -#if defined(COMPILE_ZODIAC) -#	define malloc	MemPtrNew -#elif defined(COMPILE_OS5) && defined(PALMOS_ARM) +#ifdef STDLIB_TRACE_MEMORY  #	define malloc	__malloc +	extern UInt32 __stdlib_trace_memory;  #else -#	define malloc	MemGluePtrNew +#	if defined(COMPILE_ZODIAC) +#		define malloc	MemPtrNew +#	elif defined(COMPILE_OS5) && defined(PALMOS_ARM) +#		define malloc	__malloc +#	else +#		define malloc	MemGluePtrNew +#	endif  #endif  /* custom exit (true exit !) */  | 
