Changeset 10895
- Timestamp:
- Jan 3, 2007, 12:07:23 PM (19 years ago)
- File:
-
- 1 edited
-
branches/jch-memory/psLib/src/sys/psMemory.c (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/jch-memory/psLib/src/sys/psMemory.c
r10894 r10895 8 8 * @author Robert Lupton, Princeton University 9 9 * 10 * @version $Revision: 1.88.2. 7$ $Name: not supported by cvs2svn $11 * @date $Date: 2007-01-03 22:0 4:42$10 * @version $Revision: 1.88.2.8 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2007-01-03 22:07:23 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 69 69 fprintf(stderr, "\n"); 70 70 71 static psS32 checkMemBlock(const psMemBlock* m, const char *funcName);71 static bool badMemBlock(const psMemBlock* m, const char *funcName); 72 72 static psMemBlock* lastMemBlockAllocated = NULL; 73 73 static pthread_mutex_t memBlockListMutex = PTHREAD_MUTEX_INITIALIZER; … … 137 137 * N.b. If the block wasn't allocated by psAlloc, it will appear corrupted 138 138 */ 139 static psS32 checkMemBlock(const psMemBlock* m,140 const char *funcName)139 static bool badMemBlock(const psMemBlock* m, 140 const char *funcName) 141 141 { 142 142 // n.b. since this is called by psMemCheckCorruption while the memblock list is mutex locked, … … 146 146 PS_MEM_ERROR(PS_ERR_MEMORY_CORRUPTION, true, 147 147 _("NULL memory block found.")); 148 return 1;148 return true; 149 149 } 150 150 … … 154 154 _("Memory block %lu was freed but still being used."), 155 155 (unsigned long)m->id); 156 return 1;156 return true; 157 157 } 158 158 … … 161 161 _("Memory block %lu is corrupted; buffer underflow detected."), 162 162 (unsigned long)m->id); 163 return 1;163 return true; 164 164 } 165 165 if (*(psPtr *)((int8_t *) (m + 1) + m->userMemorySize) != P_PS_MEMMAGIC) { … … 167 167 _("Memory block %lu is corrupted; buffer overflow detected."), 168 168 (unsigned long)m->id); 169 return 1;170 } 171 172 return 0;169 return true; 170 } 171 172 return false; 173 173 } 174 174 … … 303 303 { 304 304 psS32 nbad = 0; // number of bad blocks 305 psBool failure = false;306 305 307 306 // get exclusive access to the memBlock list to avoid it changing on us … … 310 309 311 310 for (psMemBlock* iter = lastMemBlockAllocated; iter != NULL; iter = iter->nextBlock) { 312 if ( checkMemBlock(iter, __func__)) {311 if (badMemBlock(iter, __func__)) { 313 312 nbad++; 314 313 … … 413 412 psMemBlock *ptr = ((psMemBlock*)vptr) - 1; 414 413 415 if ( checkMemBlock(ptr, __func__) != 0) {414 if (badMemBlock(ptr, __func__) != 0) { 416 415 memProblemCallback(ptr, file, lineno); 417 416 PS_MEM_ABORT(file, "Realloc detected a memory corruption (id %lu @ %s:%d).", … … 477 476 } 478 477 479 if ( checkMemBlock(ptr, __func__) != 0) {478 if (badMemBlock(ptr, __func__) != 0) { 480 479 memProblemCallback(ptr, filename, lineno); 481 480 PS_MEM_ABORT(__func__,"Memory Corruption Detected."); … … 558 557 ptr2 = ((psMemBlock* ) ptr) - 1; 559 558 560 if ( checkMemBlock(ptr2, __func__) != 0) {559 if (badMemBlock(ptr2, __func__) != 0) { 561 560 memProblemCallback(ptr2, __func__, __LINE__); 562 561 } … … 582 581 ptr = ((psMemBlock* ) vptr) - 1; 583 582 584 if ( checkMemBlock(ptr, __func__)) {583 if (badMemBlock(ptr, __func__)) { 585 584 memProblemCallback(ptr, file, lineno); 586 585 } … … 615 614 ptr = ((psMemBlock* ) vptr) - 1; 616 615 617 if ( checkMemBlock(ptr, __func__)) {616 if (badMemBlock(ptr, __func__)) { 618 617 memProblemCallback(ptr, file, lineno); 619 618 } … … 641 640 psMemBlock* ptr = ((psMemBlock* ) vptr) - 1; 642 641 643 if ( checkMemBlock(ptr, __func__) != 0) {642 if (badMemBlock(ptr, __func__) != 0) { 644 643 memProblemCallback(ptr, file, lineno); 645 644 return NULL; … … 694 693 psMemBlock* PTR = ((psMemBlock* ) ptr) - 1; 695 694 696 if ( checkMemBlock(PTR, __func__) != 0) {695 if (badMemBlock(PTR, __func__) != 0) { 697 696 memProblemCallback(PTR, __func__, __LINE__); 698 697 } … … 710 709 psMemBlock* PTR = ((psMemBlock* ) ptr) - 1; 711 710 712 if ( checkMemBlock(PTR, __func__) != 0) {711 if (badMemBlock(PTR, __func__) != 0) { 713 712 memProblemCallback(PTR, __func__, __LINE__); 714 713 } … … 1006 1005 psMemBlock* ptr = ((psMemBlock* ) vptr) - 1; 1007 1006 1008 if ( checkMemBlock(ptr, __func__) != 0) {1007 if (badMemBlock(ptr, __func__) != 0) { 1009 1008 memProblemCallback(ptr, __func__, __LINE__); 1010 1009 } … … 1022 1021 psMemBlock* ptr = ((psMemBlock* ) vptr) - 1; 1023 1022 1024 if ( checkMemBlock(ptr, __func__) != 0) {1023 if (badMemBlock(ptr, __func__) != 0) { 1025 1024 memProblemCallback(ptr, __func__, __LINE__); 1026 1025 }
Note:
See TracChangeset
for help on using the changeset viewer.
