00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024
00025
00026
00027 #include <PalmOS.h>
00028 #include "MemLeak.h"
00029
00030 #if ERROR_CHECK_LEVEL == ERROR_CHECK_FULL
00031
00032 static const char *LEAK_OUT_NAME = "leaks.txt";
00033
00034 MemPtr _SafeMemPtrNew(UInt32 size, Char *file, UInt32 line)
00035 {
00036 MemPtr addr = MemPtrNew(size);
00037
00038 HostFILE *hf = HostFOpen(LEAK_OUT_NAME,"a");
00039 if (hf)
00040 {
00041 HostFPrintF(hf,"@ 0x%lx 0x%lx %s %ld\n", (UInt32)addr, size, file, line);
00042 HostFClose(hf);
00043 }
00044
00045 return addr;
00046 }
00047
00048 Err _SafeMemPtrFree(void *addr, Char *file, UInt32 line)
00049 {
00050 ErrFatalDisplayIf(addr == NULL, "_SafeMemPtrFree: addr == 0!");
00051
00052 Err error = MemPtrFree(addr);
00053 ErrFatalDisplayIf(error != errNone, "_SafeMemPtrFree: Error!");
00054
00055
00056 HostFILE *hf = HostFOpen(LEAK_OUT_NAME,"a");
00057 if (hf)
00058 {
00059 HostFPrintF(hf,"! 0x%lx %s %ld\n", (UInt32)addr, file, line);
00060 HostFClose(hf);
00061 }
00062
00063 return error;
00064 }
00065
00066
00067 #endif