mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-27 05:32:45 +00:00
Added option to trace memory allocation
svn-id: r23904
This commit is contained in:
parent
24f55e47e1
commit
42dd017faf
@ -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;
|
||||
|
@ -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 !) */
|
||||
|
Loading…
x
Reference in New Issue
Block a user