Changeset 1810
- Timestamp:
- Sep 14, 2004, 1:48:25 PM (22 years ago)
- Location:
- trunk/psLib
- Files:
-
- 12 edited
-
src/sys/psError.c (modified) (3 diffs)
-
src/sys/psMemory.c (modified) (6 diffs)
-
src/sys/psMemory.h (modified) (3 diffs)
-
src/sys/psTrace.c (modified) (4 diffs)
-
src/sysUtils/psError.c (modified) (3 diffs)
-
src/sysUtils/psMemory.c (modified) (6 diffs)
-
src/sysUtils/psMemory.h (modified) (3 diffs)
-
src/sysUtils/psTrace.c (modified) (4 diffs)
-
test/dataManip/tst_psFunc00.c (modified) (10 diffs)
-
test/dataManip/tst_psMinimize05.c (modified) (1 diff)
-
test/dataManip/tst_psStats07.c (modified) (1 diff)
-
test/psTest.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psError.c
r1807 r1810 10 10 * @author Eric Van Alst, MHPCC 11 11 * 12 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-09-14 2 0:01:52$12 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-09-14 23:48:25 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 40 40 errorStack[errorStackSize] = psMemIncrRefCounter(err); 41 41 errorStackSize++; 42 p_psMemSetPersistent(err,true); 43 p_psMemSetPersistent(err->msg,true); 44 p_psMemSetPersistent(err->name,true); 42 45 } 43 46 … … 83 86 pthread_mutex_lock(&lockErrorStack); 84 87 for (int lcv=0;lcv<errorStackSize;lcv++) { 88 p_psMemSetPersistent(errorStack[lcv]->msg,false); 89 p_psMemSetPersistent(errorStack[lcv]->name,false); 90 p_psMemSetPersistent(errorStack[lcv],false); 85 91 psFree(errorStack[lcv]); 86 92 } -
trunk/psLib/src/sys/psMemory.c
r1730 r1810 1 2 1 /** @file psMemory.c 3 2 * … … 9 8 * @author Robert Lupton, Princeton University 10 9 * 11 * @version $Revision: 1.3 7$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-09- 08 21:06:00$10 * @version $Revision: 1.38 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2004-09-14 23:48:25 $ 13 12 * 14 13 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 341 340 ptr->file = file; 342 341 ptr->freeFcn = NULL; 342 ptr->persistent = false; 343 343 *(unsigned int *)&ptr->lineno = lineno; 344 344 *(void **)((int8_t *) (ptr + 1) + size) = P_PS_MEMMAGIC; … … 446 446 447 447 for (psMemBlock* iter = topBlock; iter != NULL; iter = iter->nextBlock) { 448 if ((psMemGetRefCounter(iter + 1) > 0) && (iter->id >= id0)) { 448 if ( (iter->refCounter > 0) && 449 (! iter->persistent) && 450 (iter->id >= id0)) { 451 449 452 nleak++; 450 453 … … 469 472 470 473 for (psMemBlock* iter = topBlock; iter != NULL; iter = iter->nextBlock) { 471 if ((psMemGetRefCounter(iter + 1) > 0) && (iter->id >= id0)) { 474 if ( (iter->refCounter > 0) && 475 (! iter->persistent) && 476 (iter->id >= id0)) { 477 472 478 (*arr)[j++] = iter; 473 479 if (j == nleak) { // found them all … … 651 657 return ptr->freeFcn; 652 658 } 659 660 bool p_psMemGetPersistent(void *vptr) 661 { 662 if (vptr == NULL) { 663 return NULL; 664 } 665 666 psMemBlock* ptr = ((psMemBlock* ) vptr) - 1; 667 668 if (checkMemBlock(ptr, __func__) != 0) { 669 memProblemCallback(ptr, __func__, __LINE__); 670 } 671 672 return ptr->persistent; 673 } 674 675 void p_psMemSetPersistent(void *vptr,bool value) 676 { 677 if (vptr == NULL) { 678 return; 679 } 680 681 psMemBlock* ptr = ((psMemBlock* ) vptr) - 1; 682 683 if (checkMemBlock(ptr, __func__) != 0) { 684 memProblemCallback(ptr, __func__, __LINE__); 685 } 686 687 ptr->persistent = value; 688 } -
trunk/psLib/src/sys/psMemory.h
r1606 r1810 12 12 * @ingroup MemoryManagement 13 13 * 14 * @version $Revision: 1. 29$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-0 8-23 22:36:03$14 * @version $Revision: 1.30 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-09-14 23:48:25 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 73 73 pthread_mutex_t refCounterMutex; ///< mutex to ensure exclusive access to reference counter 74 74 psReferenceCount refCounter; ///< how many times pointer is referenced 75 bool persistent; ///< marks if this non-user persistent data like error stack, etc. 75 76 const void *endblock; ///< initialised to p_psMEMMAGIC 76 77 } … … 163 164 void *ptr ///< the memory block 164 165 ); 166 167 /** Set the memory as persistent so that it is ignored when detecting memory leaks. 168 * 169 * Used to mark a memory block as persistent data within the library, 170 * i.e., non user-level data used to hold psLib's state or cache data. Such 171 * examples of this class of memory is psTrace's trace-levels and dynamic 172 * error codes. 173 * 174 * Memory marked as persistent is excluded from memory leak checks. 175 * 176 */ 177 void p_psMemSetPersistent( 178 void *ptr, ///< the memory block to operate on 179 bool value ///< true if memory is persistent, otherwise false 180 ); 181 182 /** Get the memory's persistent flag. 183 * 184 * Checks if a memory block has been marked as persistent by 185 * p_psMemSetPresistent. 186 * 187 * Memory marked as persistent is excluded from memory leak checks. 188 * 189 * @return bool true if memory is marked persistent, otherwise false. 190 */ 191 bool p_psMemGetPersistent( 192 void *ptr ///< the memory block to check. 193 ); 194 165 195 166 196 /** Memory re-allocation. This operates much like realloc(), but is guaranteed to return a non-NULL value. -
trunk/psLib/src/sys/psTrace.c
r1744 r1810 9 9 * @author George Gusciora, MHPCC 10 10 * 11 * @version $Revision: 1.3 3$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-09- 09 01:46:15 $11 * @version $Revision: 1.34 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-09-14 23:48:25 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 65 65 p_psComponent* comp = psAlloc(sizeof(p_psComponent)); 66 66 67 p_psMemSetPersistent(comp,true); 67 68 p_psMemSetDeallocator(comp, (psFreeFcn) componentFree); 68 69 comp->name = psStringCopy(name); 70 p_psMemSetPersistent((void*)comp->name,true); 69 71 comp->level = level; 70 72 comp->n = 0; … … 85 87 if (comp->subcomp != NULL) { 86 88 for (int i = 0; i < comp->n; i++) { 89 p_psMemSetPersistent(comp->subcomp[i],false); 87 90 psFree(comp->subcomp[i]); 88 91 } 92 p_psMemSetPersistent(comp->subcomp,false); 89 93 psFree(comp->subcomp); 90 94 } 91 95 92 psFree((char *)comp->name); 96 p_psMemSetPersistent((void*)comp->name,false); 97 psFree((void*)comp->name); 93 98 } 94 99 … … 195 200 currentNode->subcomp = psRealloc(currentNode->subcomp, 196 201 (currentNode->n + 1) * sizeof(p_psComponent* )); 202 p_psMemSetPersistent(currentNode->subcomp,true); 203 197 204 currentNode->n = (currentNode->n) + 1; 198 205 -
trunk/psLib/src/sysUtils/psError.c
r1807 r1810 10 10 * @author Eric Van Alst, MHPCC 11 11 * 12 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-09-14 2 0:01:52$12 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-09-14 23:48:25 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 40 40 errorStack[errorStackSize] = psMemIncrRefCounter(err); 41 41 errorStackSize++; 42 p_psMemSetPersistent(err,true); 43 p_psMemSetPersistent(err->msg,true); 44 p_psMemSetPersistent(err->name,true); 42 45 } 43 46 … … 83 86 pthread_mutex_lock(&lockErrorStack); 84 87 for (int lcv=0;lcv<errorStackSize;lcv++) { 88 p_psMemSetPersistent(errorStack[lcv]->msg,false); 89 p_psMemSetPersistent(errorStack[lcv]->name,false); 90 p_psMemSetPersistent(errorStack[lcv],false); 85 91 psFree(errorStack[lcv]); 86 92 } -
trunk/psLib/src/sysUtils/psMemory.c
r1730 r1810 1 2 1 /** @file psMemory.c 3 2 * … … 9 8 * @author Robert Lupton, Princeton University 10 9 * 11 * @version $Revision: 1.3 7$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-09- 08 21:06:00$10 * @version $Revision: 1.38 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2004-09-14 23:48:25 $ 13 12 * 14 13 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 341 340 ptr->file = file; 342 341 ptr->freeFcn = NULL; 342 ptr->persistent = false; 343 343 *(unsigned int *)&ptr->lineno = lineno; 344 344 *(void **)((int8_t *) (ptr + 1) + size) = P_PS_MEMMAGIC; … … 446 446 447 447 for (psMemBlock* iter = topBlock; iter != NULL; iter = iter->nextBlock) { 448 if ((psMemGetRefCounter(iter + 1) > 0) && (iter->id >= id0)) { 448 if ( (iter->refCounter > 0) && 449 (! iter->persistent) && 450 (iter->id >= id0)) { 451 449 452 nleak++; 450 453 … … 469 472 470 473 for (psMemBlock* iter = topBlock; iter != NULL; iter = iter->nextBlock) { 471 if ((psMemGetRefCounter(iter + 1) > 0) && (iter->id >= id0)) { 474 if ( (iter->refCounter > 0) && 475 (! iter->persistent) && 476 (iter->id >= id0)) { 477 472 478 (*arr)[j++] = iter; 473 479 if (j == nleak) { // found them all … … 651 657 return ptr->freeFcn; 652 658 } 659 660 bool p_psMemGetPersistent(void *vptr) 661 { 662 if (vptr == NULL) { 663 return NULL; 664 } 665 666 psMemBlock* ptr = ((psMemBlock* ) vptr) - 1; 667 668 if (checkMemBlock(ptr, __func__) != 0) { 669 memProblemCallback(ptr, __func__, __LINE__); 670 } 671 672 return ptr->persistent; 673 } 674 675 void p_psMemSetPersistent(void *vptr,bool value) 676 { 677 if (vptr == NULL) { 678 return; 679 } 680 681 psMemBlock* ptr = ((psMemBlock* ) vptr) - 1; 682 683 if (checkMemBlock(ptr, __func__) != 0) { 684 memProblemCallback(ptr, __func__, __LINE__); 685 } 686 687 ptr->persistent = value; 688 } -
trunk/psLib/src/sysUtils/psMemory.h
r1606 r1810 12 12 * @ingroup MemoryManagement 13 13 * 14 * @version $Revision: 1. 29$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-0 8-23 22:36:03$14 * @version $Revision: 1.30 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-09-14 23:48:25 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 73 73 pthread_mutex_t refCounterMutex; ///< mutex to ensure exclusive access to reference counter 74 74 psReferenceCount refCounter; ///< how many times pointer is referenced 75 bool persistent; ///< marks if this non-user persistent data like error stack, etc. 75 76 const void *endblock; ///< initialised to p_psMEMMAGIC 76 77 } … … 163 164 void *ptr ///< the memory block 164 165 ); 166 167 /** Set the memory as persistent so that it is ignored when detecting memory leaks. 168 * 169 * Used to mark a memory block as persistent data within the library, 170 * i.e., non user-level data used to hold psLib's state or cache data. Such 171 * examples of this class of memory is psTrace's trace-levels and dynamic 172 * error codes. 173 * 174 * Memory marked as persistent is excluded from memory leak checks. 175 * 176 */ 177 void p_psMemSetPersistent( 178 void *ptr, ///< the memory block to operate on 179 bool value ///< true if memory is persistent, otherwise false 180 ); 181 182 /** Get the memory's persistent flag. 183 * 184 * Checks if a memory block has been marked as persistent by 185 * p_psMemSetPresistent. 186 * 187 * Memory marked as persistent is excluded from memory leak checks. 188 * 189 * @return bool true if memory is marked persistent, otherwise false. 190 */ 191 bool p_psMemGetPersistent( 192 void *ptr ///< the memory block to check. 193 ); 194 165 195 166 196 /** Memory re-allocation. This operates much like realloc(), but is guaranteed to return a non-NULL value. -
trunk/psLib/src/sysUtils/psTrace.c
r1745 r1810 9 9 * @author George Gusciora, MHPCC 10 10 * 11 * @version $Revision: 1.3 3$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-09- 09 01:46:15 $11 * @version $Revision: 1.34 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-09-14 23:48:25 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 65 65 p_psComponent* comp = psAlloc(sizeof(p_psComponent)); 66 66 67 p_psMemSetPersistent(comp,true); 67 68 p_psMemSetDeallocator(comp, (psFreeFcn) componentFree); 68 69 comp->name = psStringCopy(name); 70 p_psMemSetPersistent((void*)comp->name,true); 69 71 comp->level = level; 70 72 comp->n = 0; … … 85 87 if (comp->subcomp != NULL) { 86 88 for (int i = 0; i < comp->n; i++) { 89 p_psMemSetPersistent(comp->subcomp[i],false); 87 90 psFree(comp->subcomp[i]); 88 91 } 92 p_psMemSetPersistent(comp->subcomp,false); 89 93 psFree(comp->subcomp); 90 94 } 91 95 92 psFree((char *)comp->name); 96 p_psMemSetPersistent((void*)comp->name,false); 97 psFree((void*)comp->name); 93 98 } 94 99 … … 195 200 currentNode->subcomp = psRealloc(currentNode->subcomp, 196 201 (currentNode->n + 1) * sizeof(p_psComponent* )); 202 p_psMemSetPersistent(currentNode->subcomp,true); 203 197 204 currentNode->n = (currentNode->n) + 1; 198 205 -
trunk/psLib/test/dataManip/tst_psFunc00.c
r1809 r1810 237 237 238 238 psFree(my3DPolyD); 239 memLeaks = psMemCheckLeaks(currentId,NULL, NULL);239 memLeaks = psMemCheckLeaks(currentId,NULL,stderr); 240 240 if (0 != memLeaks) { 241 241 psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks); … … 271 271 272 272 psFree(my4DPolyD); 273 memLeaks = psMemCheckLeaks(currentId,NULL, NULL);273 memLeaks = psMemCheckLeaks(currentId,NULL,stderr); 274 274 if (0 != memLeaks) { 275 275 psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks); … … 301 301 302 302 psFree(my1DPoly); 303 memLeaks = psMemCheckLeaks(currentId,NULL, NULL);303 memLeaks = psMemCheckLeaks(currentId,NULL,stderr); 304 304 if (0 != memLeaks) { 305 305 psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks); … … 330 330 331 331 psFree(my2DPoly); 332 memLeaks = psMemCheckLeaks(currentId,NULL, NULL);332 memLeaks = psMemCheckLeaks(currentId,NULL,stderr); 333 333 if (0 != memLeaks) { 334 334 psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks); … … 361 361 362 362 psFree(my3DPoly); 363 memLeaks = psMemCheckLeaks(currentId,NULL, NULL);363 memLeaks = psMemCheckLeaks(currentId,NULL,stderr); 364 364 if (0 != memLeaks) { 365 365 psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks); … … 395 395 396 396 psFree(my4DPoly); 397 memLeaks = psMemCheckLeaks(currentId,NULL, NULL);397 memLeaks = psMemCheckLeaks(currentId,NULL,stderr); 398 398 if (0 != memLeaks) { 399 399 psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks); … … 425 425 426 426 psFree(my1DPolyD); 427 memLeaks = psMemCheckLeaks(currentId,NULL, NULL);427 memLeaks = psMemCheckLeaks(currentId,NULL,stderr); 428 428 if (0 != memLeaks) { 429 429 psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks); … … 451 451 452 452 psFree(my2DPolyD); 453 memLeaks = psMemCheckLeaks(currentId,NULL, NULL);453 memLeaks = psMemCheckLeaks(currentId,NULL,stderr); 454 454 if (0 != memLeaks) { 455 455 psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks); … … 482 482 483 483 psFree(my3DPolyD); 484 memLeaks = psMemCheckLeaks(currentId,NULL, NULL);484 memLeaks = psMemCheckLeaks(currentId,NULL,stderr); 485 485 if (0 != memLeaks) { 486 486 psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks); … … 516 516 517 517 psFree(my4DPolyD); 518 memLeaks = psMemCheckLeaks(currentId,NULL, NULL);518 memLeaks = psMemCheckLeaks(currentId,NULL,stderr); 519 519 if (0 != memLeaks) { 520 520 psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks); -
trunk/psLib/test/dataManip/tst_psMinimize05.c
r1800 r1810 99 99 100 100 psMemCheckCorruption(1); 101 memLeaks = psMemCheckLeaks(currentId,NULL, NULL);101 memLeaks = psMemCheckLeaks(currentId,NULL,stderr); 102 102 if (0 != memLeaks) { 103 103 psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks); -
trunk/psLib/test/dataManip/tst_psStats07.c
r1406 r1810 402 402 403 403 psMemCheckCorruption( 1 ); 404 memLeaks = psMemCheckLeaks( currentId, NULL, NULL);404 memLeaks = psMemCheckLeaks( currentId, NULL, stderr ); 405 405 if ( 0 != memLeaks ) { 406 406 psAbort( __func__, "Memory Leaks! (%d leaks)", memLeaks ); -
trunk/psLib/test/psTest.c
r1699 r1810 149 149 int currentId = psMemGetId(); 150 150 int retVal = fcn(); 151 psErrorClear(); // clear the error stack before checking for leaks152 psTraceReset();153 151 if ( retVal == 0 ) { // only bother checking memory if test executed to end. 154 152 if ( psMemCheckLeaks( currentId, NULL, stderr ) != 0 ) { … … 175 173 int currentId = psMemGetId(); 176 174 childReturn = fcn(); 177 psErrorClear(); // clear the error stack before checking for leaks178 psTraceReset();179 175 if ( childReturn == 0 ) { // only bother checking memory if test executed to end. 180 176 if ( psMemCheckLeaks( currentId, NULL, stderr ) != 0 ) {
Note:
See TracChangeset
for help on using the changeset viewer.
