Changeset 1810 for trunk/psLib/src/sysUtils
- Timestamp:
- Sep 14, 2004, 1:48:25 PM (22 years ago)
- Location:
- trunk/psLib/src/sysUtils
- Files:
-
- 4 edited
-
psError.c (modified) (3 diffs)
-
psMemory.c (modified) (6 diffs)
-
psMemory.h (modified) (3 diffs)
-
psTrace.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.
