|
|
| version 1.1, 2003/10/16 17:57:10 | version 1.4, 2005/02/15 18:42:20 |
|---|---|
| Line 1 | Line 1 |
| #include "compiler.h" | #include "compiler.h" |
| #include "dosio.h" | |
| #define MEMTBLMAX 256 | #define MEMTBLMAX 256 |
| #define HDLTBLMAX 256 | #define HDLTBLMAX 256 |
| #if defined(MEMTRACE) | #if defined(MEMTRACE) |
| #include "strres.h" | |
| #include "dosio.h" | |
| #if defined(MACOS) | |
| #define CRLITERAL "\r" | |
| #define CRCONST str_cr | |
| #elif defined(X11) || defined(SLZAURUS) | |
| #define CRLITERAL "\n" | |
| #define CRCONST str_lf | |
| #else | |
| #define CRLITERAL "\r\n" | |
| #define CRCONST str_crlf | |
| #endif | |
| typedef struct { | typedef struct { |
| void *hdl; | void *hdl; |
| UINT size; | UINT size; |
| Line 21 typedef struct { | Line 35 typedef struct { |
| static _MEMTBL memtbl[MEMTBLMAX]; | static _MEMTBL memtbl[MEMTBLMAX]; |
| static _HDLTBL hdltbl[HDLTBLMAX]; | static _HDLTBL hdltbl[HDLTBLMAX]; |
| static const char memstr[] = \ | static const OEMCHAR str_memhdr[] = \ |
| "Handle Size Name\r\n" \ | "Handle Size Name" CRLITERAL \ |
| "--------------------------------------------\r\n"; | "--------------------------------------------" CRLITERAL; |
| static const char hdlstr[] = \ | static const OEMCHAR str_hdlhdr[] = \ |
| "Handle Name\r\n" \ | "Handle Name" CRLITERAL \ |
| "-------------------------------------\r\n"; | "-------------------------------------" CRLITERAL; |
| static const OEMCHAR str_memused[] = "memused: %d" CRLITERAL; | |
| void _meminit(void) { | void _meminit(void) { |
| Line 69 void _memfree(void *hdl) { | Line 85 void _memfree(void *hdl) { |
| } | } |
| } | } |
| void _handle_append(void *hdl, const char *name) { | void _handle_append(void *hdl, const OEMCHAR *name) { |
| int i; | int i; |
| Line 77 void _handle_append(void *hdl, const cha | Line 93 void _handle_append(void *hdl, const cha |
| for (i=0; i<HDLTBLMAX; i++) { | for (i=0; i<HDLTBLMAX; i++) { |
| if (hdltbl[i].hdl == NULL) { | if (hdltbl[i].hdl == NULL) { |
| hdltbl[i].hdl = hdl; | hdltbl[i].hdl = hdl; |
| milstr_ncpy(hdltbl[i].name, name, sizeof(hdltbl[0].name))); | milstr_ncpy(hdltbl[i].name, name, sizeof(hdltbl[0].name)); |
| break; | break; |
| } | } |
| } | } |
| Line 97 void _handle_remove(void *hdl) { | Line 113 void _handle_remove(void *hdl) { |
| } | } |
| } | } |
| void _memused(const char *filename) { | void _memused(const OEMCHAR *filename) { |
| int i; | int i; |
| FILEH fh; | FILEH fh; |
| int memuses = 0; | int memuses = 0; |
| int hdluses = 0; | int hdluses = 0; |
| BYTE memusebit[(MEMTBLMAX+7)/8]; | UINT8 memusebit[(MEMTBLMAX+7)/8]; |
| BYTE hdlusebit[(HDLTBLMAX+7)/8]; | UINT8 hdlusebit[(HDLTBLMAX+7)/8]; |
| char work[256]; | OEMCHAR work[256]; |
| ZeroMemory(memusebit, sizeof(memusebit)); | ZeroMemory(memusebit, sizeof(memusebit)); |
| ZeroMemory(hdlusebit, sizeof(hdlusebit)); | ZeroMemory(hdlusebit, sizeof(hdlusebit)); |
| for (i=0; i<MEMTBLMAX; i++) { | for (i=0; i<MEMTBLMAX; i++) { |
| if (memtbl[i].hdl) { | if (memtbl[i].hdl) { |
| memusebit[i>>3] |= (BYTE)0x80 >> (i & 7); | memusebit[i>>3] |= (UINT8)(0x80 >> (i & 7)); |
| memuses++; | memuses++; |
| } | } |
| } | } |
| for (i=0; i<HDLTBLMAX; i++) { | for (i=0; i<HDLTBLMAX; i++) { |
| if (hdltbl[i].hdl) { | if (hdltbl[i].hdl) { |
| hdlusebit[i>>3] |= (BYTE)0x80 >> (i & 7); | hdlusebit[i>>3] |= (UINT8)(0x80 >> (i & 7)); |
| hdluses++; | hdluses++; |
| } | } |
| } | } |
| fh = file_create_c(filename); | fh = file_create_c(filename); |
| if (fh != FILEH_INVALID) { | if (fh != FILEH_INVALID) { |
| SPRINTF(work, "memused: %d\r\n", memuses); | OEMSPRINTF(work, OEMTEXT("memused: %d\r\n"), memuses); |
| file_write(fh, work, strlen(work)); | file_write(fh, work, OEMSTRLEN(work)); |
| if (memuses) { | if (memuses) { |
| file_write(fh, memstr, strlen(memstr)); | file_write(fh, str_memhdr, OEMSTRLEN(str_memhdr)); |
| for (i=0; i<MEMTBLMAX; i++) { | for (i=0; i<MEMTBLMAX; i++) { |
| if ((memusebit[i>>3] << (i & 7)) & 0x80) { | if ((memusebit[i>>3] << (i & 7)) & 0x80) { |
| SPRINTF(work, "%08lx %10u %s\r\n", | OEMSPRINTF(work, OEMTEXT("%08lx %10u %s\r\n"), |
| (long)memtbl[i].hdl, memtbl[i].size, memtbl[i].name); | (long)memtbl[i].hdl, memtbl[i].size, memtbl[i].name); |
| file_write(fh, work, strlen(work)); | file_write(fh, work, OEMSTRLEN(work)); |
| } | } |
| } | } |
| file_write(fh, "\r\n", 2); | file_write(fh, CRCONST, OEMSTRLEN(CRCONST)); |
| } | } |
| SPRINTF(work, "hdlused: %d\r\n", hdluses); | OEMSPRINTF(work, "hdlused: %d\r\n", hdluses); |
| file_write(fh, work, strlen(work)); | file_write(fh, work, OEMSTRLEN(work)); |
| if (hdluses) { | if (hdluses) { |
| file_write(fh, hdlstr, strlen(hdlstr)); | file_write(fh, str_hdlhdr, OEMSTRLEN(str_hdlhdr)); |
| for (i=0; i<HDLTBLMAX; i++) { | for (i=0; i<HDLTBLMAX; i++) { |
| if ((hdlusebit[i>>3] << (i & 7)) & 0x80) { | if ((hdlusebit[i>>3] << (i & 7)) & 0x80) { |
| SPRINTF(work, "%08lx %s\r\n", | OEMSPRINTF(work, "%08lx %s\r\n", |
| (long)hdltbl[i].hdl, hdltbl[i].name); | (long)hdltbl[i].hdl, hdltbl[i].name); |
| file_write(fh, work, strlen(work)); | file_write(fh, work, OEMSTRLEN(work)); |
| } | } |
| } | } |
| file_write(fh, "\r\n", 2); | file_write(fh, CRCONST, strlen(CRCONST)); |
| } | } |
| file_close(fh); | file_close(fh); |
| } | } |
| Line 160 typedef struct { | Line 176 typedef struct { |
| UINT size; | UINT size; |
| } _MEMTBL; | } _MEMTBL; |
| UINT usedmemory; | |
| BOOL chgmemory; | BOOL chgmemory; |
| UINT usedmemory; | |
| static _MEMTBL memtbl[MEMTBLMAX]; | static _MEMTBL memtbl[MEMTBLMAX]; |
| void _meminit(void) { | void _meminit(void) { |