Changeset 4401 for trunk/psLib/src/sys
- Timestamp:
- Jun 27, 2005, 10:38:12 AM (21 years ago)
- Location:
- trunk/psLib/src/sys
- Files:
-
- 2 edited
-
psMemory.c (modified) (5 diffs)
-
psMemory.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psMemory.c
r4397 r4401 8 8 * @author Robert Lupton, Princeton University 9 9 * 10 * @version $Revision: 1.5 6$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-06-2 5 03:32:42 $10 * @version $Revision: 1.57 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-06-27 20:38:12 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 342 342 343 343 ptr->file = file; 344 ptr->freeF cn= NULL;344 ptr->freeFunc = NULL; 345 345 ptr->persistent = false; 346 346 *(psU32 *)&ptr->lineno = lineno; … … 576 576 pthread_mutex_unlock(&ptr->refCounterMutex); 577 577 578 if (ptr->freeF cn!= NULL) {579 ptr->freeF cn(vptr);578 if (ptr->freeFunc != NULL) { 579 ptr->freeFunc(vptr); 580 580 } 581 581 … … 640 640 } 641 641 642 void psMemSetDeallocator(psPtr vptr, psFreeFunc freeFcn) 642 void psMemSetDeallocator(psPtr ptr, psFreeFunc freeFunc) 643 { 644 if (ptr == NULL) { 645 return; 646 } 647 648 psMemBlock* PTR = ((psMemBlock* ) ptr) - 1; 649 650 if (checkMemBlock(PTR, __func__) != 0) { 651 memProblemCallback(PTR, __func__, __LINE__); 652 } 653 654 PTR->freeFunc = freeFunc; 655 656 } 657 psFreeFunc psMemGetDeallocator(psPtr ptr) 658 { 659 if (ptr == NULL) { 660 return NULL; 661 } 662 663 psMemBlock* PTR = ((psMemBlock* ) ptr) - 1; 664 665 if (checkMemBlock(PTR, __func__) != 0) { 666 memProblemCallback(PTR, __func__, __LINE__); 667 } 668 669 return PTR->freeFunc; 670 } 671 672 bool p_psMemGetPersistent(psPtr vptr) 673 { 674 if (vptr == NULL) { 675 return NULL; 676 } 677 678 psMemBlock* ptr = ((psMemBlock* ) vptr) - 1; 679 680 if (checkMemBlock(ptr, __func__) != 0) { 681 memProblemCallback(ptr, __func__, __LINE__); 682 } 683 684 return ptr->persistent; 685 } 686 687 void p_psMemSetPersistent(psPtr vptr, bool value) 643 688 { 644 689 if (vptr == NULL) { … … 652 697 } 653 698 654 ptr->freeFcn = freeFcn;655 656 }657 psFreeFunc psMemGetDeallocator(psPtr vptr)658 {659 if (vptr == NULL) {660 return NULL;661 }662 663 psMemBlock* ptr = ((psMemBlock* ) vptr) - 1;664 665 if (checkMemBlock(ptr, __func__) != 0) {666 memProblemCallback(ptr, __func__, __LINE__);667 }668 669 return ptr->freeFcn;670 }671 672 bool p_psMemGetPersistent(psPtr vptr)673 {674 if (vptr == NULL) {675 return NULL;676 }677 678 psMemBlock* ptr = ((psMemBlock* ) vptr) - 1;679 680 if (checkMemBlock(ptr, __func__) != 0) {681 memProblemCallback(ptr, __func__, __LINE__);682 }683 684 return ptr->persistent;685 }686 687 void p_psMemSetPersistent(psPtr vptr, bool value)688 {689 if (vptr == NULL) {690 return;691 }692 693 psMemBlock* ptr = ((psMemBlock* ) vptr) - 1;694 695 if (checkMemBlock(ptr, __func__) != 0) {696 memProblemCallback(ptr, __func__, __LINE__);697 }698 699 699 ptr->persistent = value; 700 700 } -
trunk/psLib/src/sys/psMemory.h
r4397 r4401 12 12 * @ingroup MemoryManagement 13 13 * 14 * @version $Revision: 1.4 3$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-06-2 5 03:32:42 $14 * @version $Revision: 1.44 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-06-27 20:38:12 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 67 67 struct psMemBlock* previousBlock; ///< previous block in allocation list 68 68 struct psMemBlock* nextBlock; ///< next block allocation list 69 psFreeFunc freeF cn;///< deallocator. If NULL, use generic deallocation.69 psFreeFunc freeFunc; ///< deallocator. If NULL, use generic deallocation. 70 70 size_t userMemorySize; ///< the size of the user-portion of the memory block 71 const psMemId id; ///< a unique ID for this allocation71 const psMemId id; ///< a unique ID for this allocation 72 72 const char *file; ///< set from __FILE__ in e.g. p_psAlloc 73 const psS32 lineno; ///< set from __LINE__ in e.g. p_psAlloc73 const psS32 lineno; ///< set from __LINE__ in e.g. p_psAlloc 74 74 pthread_mutex_t refCounterMutex; ///< mutex to ensure exclusive access to reference counter 75 75 psReferenceCount refCounter; ///< how many times pointer is referenced 76 psBool persistent; ///< marks if this non-user persistent data like error stack, etc.76 psBool persistent; ///< marks if this non-user persistent data like error stack, etc. 77 77 const psPtr endblock; ///< initialised to p_psMEMMAGIC 78 78 } … … 152 152 void psMemSetDeallocator( 153 153 psPtr ptr, ///< the memory block to operate on 154 psFreeFunc freeF cn///< the function to be executed at deallocation154 psFreeFunc freeFunc ///< the function to be executed at deallocation 155 155 ); 156 156
Note:
See TracChangeset
for help on using the changeset viewer.
