Changeset 5745 for trunk/stac/src/stacCheckMemory.c
- Timestamp:
- Dec 7, 2005, 4:04:22 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/stac/src/stacCheckMemory.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/stac/src/stacCheckMemory.c
r5743 r5745 4 4 5 5 6 #define LEAKS "leaks.dat" // File to which to write leaks data6 #define LEAKS "leaks.dat" // File to which to write leaks data 7 7 8 8 … … 10 10 { 11 11 psLogMsg("stac.memoryPrint", PS_LOG_INFO, 12 "Memory block %d:\n"13 "\tFile %s, line %d, size %d\n"14 "\tPosts: %x %x %x\n",15 ptr->id, ptr->file, ptr->lineno, ptr->userMemorySize, ptr->startblock, ptr->endblock,16 *(void**)((int8_t *)(ptr + 1) + ptr->userMemorySize));12 "Memory block %d:\n" 13 "\tFile %s, line %d, size %d\n" 14 "\tPosts: %x %x %x\n", 15 ptr->id, ptr->file, ptr->lineno, ptr->userMemorySize, ptr->startblock, ptr->endblock, 16 *(void**)((int8_t *)(ptr + 1) + ptr->userMemorySize)); 17 17 return 0; 18 18 } … … 20 20 21 21 void stacMemoryProblem(const psMemBlock* ptr, ///< the pointer to the problematic memory block. 22 const char *file, ///< the file in which the problem originated23 psS32 lineno///< the line number in which the problem originated22 const char *file, ///< the file in which the problem originated 23 psS32 lineno ///< the line number in which the problem originated 24 24 ) 25 25 { 26 26 psLogMsg("stac.checkMemory.corruption", PS_LOG_WARN, 27 "Memory corruption detected in memBlock %d\n"28 "\tFile %s, line %d, size %d\n"29 "\tPosts: %x %x %x\n",30 ptr->id, file, lineno, ptr->userMemorySize, ptr->startblock, ptr->endblock,31 (ptr + 1 + ptr->userMemorySize));27 "Memory corruption detected in memBlock %d\n" 28 "\tFile %s, line %d, size %d\n" 29 "\tPosts: %x %x %x\n", 30 ptr->id, file, lineno, ptr->userMemorySize, ptr->startblock, ptr->endblock, 31 (ptr + 1 + ptr->userMemorySize)); 32 32 } 33 33 … … 36 36 void stacCheckMemory(void) 37 37 { 38 psMemBlock **leaks = NULL; // List of leaks39 FILE *leakFile; // File to write leaks to38 psMemBlock **leaks = NULL; // List of leaks 39 FILE *leakFile; // File to write leaks to 40 40 41 41 psTrace("stac.checkMemory", 1, "Checking for memory problems....\n"); … … 44 44 45 45 if ((leakFile = fopen(LEAKS, "w")) == NULL) { 46 fprintf(stderr, "Unable to open leaks file, %s\n", LEAKS);47 return;46 fprintf(stderr, "Unable to open leaks file, %s\n", LEAKS); 47 return; 48 48 } 49 49 … … 51 51 psTrace("stac.checkMemory", 1, "%d leaks found.\n", nLeaks); 52 52 for (int i = 0; i < nLeaks; i++) { 53 psLogMsg("stac.checkMemory.leaks", PS_LOG_WARN,54 "Memory leak detection: memBlock %d\n"55 "\tFile %s, line %d, size %d\n",56 leaks[i]->id, leaks[i]->file, leaks[i]->lineno, leaks[i]->userMemorySize);53 psLogMsg("stac.checkMemory.leaks", PS_LOG_WARN, 54 "Memory leak detection: memBlock %d\n" 55 "\tFile %s, line %d, size %d\n", 56 leaks[i]->id, leaks[i]->file, leaks[i]->lineno, leaks[i]->userMemorySize); 57 57 } 58 58 59 int nCorrupted = psMemCheckCorruption(false); // Number of corrupted 59 int nCorrupted; // Number of corrupted memory blocks 60 nCorrupted = psMemCheckCorruption(false); 60 61 psTrace("stac.checkMemory", 1, "%d memory blocks corrupted.\n", nCorrupted); 61 62
Note:
See TracChangeset
for help on using the changeset viewer.
