Changeset 1073 for trunk/psLib/src/sys/psMemory.h
- Timestamp:
- Jun 23, 2004, 1:00:17 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/sys/psMemory.h (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psMemory.h
r978 r1073 14 14 * @ingroup MemoryManagement 15 15 * 16 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $17 * @date $Date: 2004-06- 10 02:09:57$16 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 17 * @date $Date: 2004-06-23 23:00:15 $ 18 18 * 19 19 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 50 50 /// typedef for a memory block's reference count. Guaranteed to be some variety of integer. 51 51 typedef unsigned long psReferenceCount; 52 53 /// typedef for deallocator. 54 typedef void (*psFreeFcn)(void* ptr); 52 55 53 56 /** Book-keeping data for storage allocator. … … 58 61 typedef struct psMemBlock 59 62 { 60 const void* startblock; ///< initialised to p_psMEMMAGIC 61 struct psMemBlock* previousBlock; ///< previous block in allocation list 62 struct psMemBlock* nextBlock; ///< next block allocation list 63 size_t userMemorySize; ///< the size of the user-portion of the memory block 64 const psMemoryId id; ///< a unique ID for this allocation 65 const char* file; ///< set from __FILE__ in e.g. p_psAlloc 66 const int lineno; ///< set from __LINE__ in e.g. p_psAlloc 67 pthread_mutex_t refCounterMutex; ///< mutex to ensure exclusive access to reference counter 68 psReferenceCount refCounter; ///< how many times pointer is referenced 69 const void* endblock; ///< initialised to p_psMEMMAGIC 63 const void* startblock; ///< initialised to p_psMEMMAGIC 64 struct psMemBlock* previousBlock; ///< previous block in allocation list 65 struct psMemBlock* nextBlock; ///< next block allocation list 66 psFreeFcn freeFcn; ///< deallocator. If NULL, use generic deallocation. 67 size_t userMemorySize; ///< the size of the user-portion of the memory block 68 const psMemoryId id; ///< a unique ID for this allocation 69 const char* file; ///< set from __FILE__ in e.g. p_psAlloc 70 const int lineno; ///< set from __LINE__ in e.g. p_psAlloc 71 pthread_mutex_t refCounterMutex; ///< mutex to ensure exclusive access to reference counter 72 psReferenceCount refCounter; ///< how many times pointer is referenced 73 const void* endblock; ///< initialised to p_psMEMMAGIC 70 74 } 71 75 psMemBlock; … … 114 118 ); 115 119 116 typedef void (*psFreeFcn)(void* ptr);117 118 120 /** Memory allocation. This operates much like malloc(), but is guaranteed to return a non-NULL value. 119 121 * 120 122 * @return void* pointer to the allocated buffer. This will not be NULL. 121 * @see psFree 123 * @see psFree 122 124 */ 123 125 #ifdef DOXYGEN … … 131 133 int lineno ///< Line number of call 132 134 ); 135 136 void p_psMemSetDeallocator(void* ptr, psFreeFcn freeFcn); 137 psFreeFcn p_psMemGetDeallocator(void* ptr); 138 133 139 /// Memory allocation. psAlloc sends file and line number to p_psAlloc. 134 140 #define psAlloc(size) p_psAlloc(size, __FILE__, __LINE__) … … 282 288 ); 283 289 284 #define PS_FREE (void*)1285 286 290 //@} End of Memory Management Functions 287 291 288 289 292 #ifndef DOXYGEN 290 291 void p_psCustomFree(psFreeFcn fcn,void* ptr);292 293 293 294 /*
Note:
See TracChangeset
for help on using the changeset viewer.
