Changeset 10896
- Timestamp:
- Jan 3, 2007, 12:25:33 PM (19 years ago)
- Location:
- branches/jch-memory/psLib/src/sys
- Files:
-
- 2 edited
-
psMemory.c (modified) (6 diffs)
-
psMemory.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/jch-memory/psLib/src/sys/psMemory.c
r10895 r10896 8 8 * @author Robert Lupton, Princeton University 9 9 * 10 * @version $Revision: 1.88.2. 8$ $Name: not supported by cvs2svn $11 * @date $Date: 2007-01-03 22: 07:23 $10 * @version $Revision: 1.88.2.9 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2007-01-03 22:25:33 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 363 363 *(psPtr*)&ptr->endblock = P_PS_MEMMAGIC; 364 364 ptr->userMemorySize = size; 365 if (safeThreads) { 366 pthread_mutex_init(&ptr->refCounterMutex, NULL); 367 } 368 } 365 } 366 369 367 // increment the memory id safely. 370 368 MUTEX_LOCK(&memBlockListMutex); … … 561 559 } 562 560 563 MUTEX_LOCK(&ptr2->refCounterMutex);564 561 refCount = ptr2->refCounter; 565 MUTEX_UNLOCK(&ptr2->refCounterMutex);566 562 567 563 return refCount; … … 585 581 } 586 582 587 MUTEX_LOCK(&ptr->refCounterMutex);588 583 ptr->refCounter++; 589 MUTEX_UNLOCK(&ptr->refCounterMutex);590 584 591 585 // Did the user ask to be informed about this allocation? … … 618 612 } 619 613 620 MUTEX_LOCK(&ptr->refCounterMutex);621 614 ptr->refCounter = count; 622 MUTEX_UNLOCK(&ptr->refCounterMutex);623 615 624 616 if (count < 1) { … … 650 642 } 651 643 652 MUTEX_LOCK(&ptr->refCounterMutex);653 654 644 if (ptr->refCounter > 1) { 655 645 ptr->refCounter--; // multiple references, just decrement the count. 656 MUTEX_UNLOCK(&ptr->refCounterMutex);657 658 646 } else { 659 MUTEX_UNLOCK(&ptr->refCounterMutex);660 661 647 if (ptr->freeFunc != NULL) { 662 648 ptr->freeFunc(vptr); -
branches/jch-memory/psLib/src/sys/psMemory.h
r10884 r10896 12 12 * @ingroup MemoryManagement 13 13 * 14 * @version $Revision: 1.61.2. 1$ $Name: not supported by cvs2svn $15 * @date $Date: 2007-01-03 03:36:38$14 * @version $Revision: 1.61.2.2 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2007-01-03 22:25:33 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 74 74 const char *file; ///< set from __FILE__ in e.g. p_psAlloc 75 75 const unsigned int lineno; ///< set from __LINE__ in e.g. p_psAlloc 76 pthread_mutex_t refCounterMutex; ///< mutex to ensure exclusive access to reference counter77 76 psReferenceCount refCounter; ///< how many times pointer is referenced 78 77 bool persistent; ///< marks if this non-user persistent data like error stack, etc.
Note:
See TracChangeset
for help on using the changeset viewer.
