Changeset 4444 for trunk/psLib/src/sysUtils/psMemory.h
- Timestamp:
- Jun 30, 2005, 5:57:42 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/sysUtils/psMemory.h (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sysUtils/psMemory.h
r4401 r4444 12 12 * @ingroup MemoryManagement 13 13 * 14 * @version $Revision: 1.4 4$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-0 6-27 20:38:12$14 * @version $Revision: 1.45 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-07-01 03:57:39 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 49 49 50 50 /// typedef for memory identification numbers. Guaranteed to be some variety of integer. 51 typedef psU64psMemId;51 typedef unsigned long psMemId; 52 52 53 53 /// typedef for a memory block's reference count. Guaranteed to be some variety of integer. 54 typedef psU64psReferenceCount;54 typedef unsigned long psReferenceCount; 55 55 56 56 /// typedef for deallocator. 57 typedef void (*psFreeFunc) ( psPtrptr);57 typedef void (*psFreeFunc) (void* ptr); 58 58 59 59 /** Book-keeping data for storage allocator. … … 64 64 typedef struct psMemBlock 65 65 { 66 const psPtrstartblock; ///< initialised to p_psMEMMAGIC66 const void* startblock; ///< initialised to p_psMEMMAGIC 67 67 struct psMemBlock* previousBlock; ///< previous block in allocation list 68 68 struct psMemBlock* nextBlock; ///< next block allocation list … … 71 71 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 unsigned int 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.77 const psPtrendblock; ///< initialised to p_psMEMMAGIC76 bool persistent; ///< marks if this non-user persistent data like error stack, etc. 77 const void* endblock; ///< initialised to p_psMEMMAGIC 78 78 } 79 79 psMemBlock; … … 81 81 /** prototype of a basic callback used by memory functions 82 82 * 83 * @see psMemAlloc ateCallbackSet84 * @ingroup memCallback 85 */ 86 typedef psMemId(*psMemAlloc ateCallback) (83 * @see psMemAllocCallbackSet 84 * @ingroup memCallback 85 */ 86 typedef psMemId(*psMemAllocCallback) ( 87 87 const psMemBlock* ptr ///< the psMemBlock just allocated 88 88 ); … … 105 105 */ 106 106 typedef void (*psMemProblemCallback) ( 107 const psMemBlock* ptr,///< the pointer to the problematic memory block.108 const char *file ,///< the file in which the problem originated109 psS32 lineno///< the line number in which the problem originated107 psMemBlock* ptr, ///< the pointer to the problematic memory block. 108 const char *filename, ///< the file in which the problem originated 109 unsigned int lineno ///< the line number in which the problem originated 110 110 ); 111 111 … … 118 118 * @ingroup memCallback 119 119 */ 120 typedef psPtr(*psMemExhaustedCallback) (120 typedef void* (*psMemExhaustedCallback) ( 121 121 size_t size ///< the size of buffer required 122 122 ); … … 128 128 */ 129 129 #ifdef DOXYGEN 130 psPtr psAlloc(size_t size ///< Size required 131 ); 130 131 psPtr psAlloc( 132 size_t size ///< Size required 133 ); 134 132 135 #else // #ifdef DOXYGEN 133 psPtr p_psAlloc(size_t size, ///< Size required 134 const char *file, ///< File of call 135 psS32 lineno ///< Line number of call 136 ); 136 psPtr p_psAlloc( 137 size_t size, ///< Size required 138 const char *filename, ///< File of call 139 unsigned int lineno ///< Line number of call 140 ); 137 141 138 142 /// Memory allocation. psAlloc sends file and line number to p_psAlloc. … … 203 207 */ 204 208 #ifdef DOXYGEN 209 205 210 psPtr psRealloc( 206 psPtr ptr, ///< Pointer to re-allocate207 size_t size ///< Size required211 psPtr ptr, ///< Pointer to re-allocate 212 size_t size ///< Size required 208 213 ); 209 214 #else // #ifdef DOXYGEN 215 210 216 psPtr p_psRealloc( 211 217 psPtr ptr, ///< Pointer to re-allocate 212 218 size_t size, ///< Size required 213 const char *file ,///< File of call214 psS32 lineno///< Line number of call219 const char *filename, ///< File of call 220 unsigned int lineno ///< Line number of call 215 221 ); 216 222 … … 234 240 psPtr ptr, ///< Pointer to free 235 241 const char *file, ///< File of call 236 psS32 lineno///< Line number of call242 unsigned int lineno ///< Line number of call 237 243 ); 238 244 … … 259 265 */ 260 266 psS32 psMemCheckLeaks( 261 psMemId id0, ///< don't list blocks with id < id0267 psMemId id0, ///< don't list blocks with id < id0 262 268 psMemBlock* ** arr, ///< pointer to array of pointers to leaked blocks, or NULL 263 269 FILE * fd, ///< print list of leaks to fd (or NULL) … … 288 294 #ifdef DOXYGEN 289 295 psPtr psMemIncrRefCounter( 290 const psPtr ptr ///< Pointer to increment refCounter, and return296 const psPtr ptr ///< Pointer to increment refCounter, and return 291 297 ); 292 298 #else … … 294 300 psPtr vptr, ///< Pointer to increment refCounter, and return 295 301 const char *file, ///< File of call 296 psS32 lineno ///< Line number of call302 psS32 lineno ///< Line number of call 297 303 ); 298 304 … … 318 324 psPtr vptr, ///< Pointer to decrement refCounter, and return 319 325 const char *file, ///< File of call 320 psS32 lineno ///< Line number of call326 psS32 lineno ///< Line number of call 321 327 ); 322 328 … … 362 368 /** Set call back for when a particular memory block is allocated 363 369 * 364 * A private variable, p_psMemAlloc ateID, can be used to trace the allocation365 * and freeing of specific memory blocks. If p_psMemAlloc ateID is set and a366 * memory block with that ID is allocated, psMemAlloc ateCallback is called370 * A private variable, p_psMemAllocID, can be used to trace the allocation 371 * and freeing of specific memory blocks. If p_psMemAllocID is set and a 372 * memory block with that ID is allocated, psMemAllocCallback is called 367 373 * just before memory is returned to the calling function. 368 374 * 369 375 * @ingroup memCallback 370 376 * 371 * @return psMemAlloc ateCallback old psMemAllocateCallback function372 */ 373 psMemAlloc ateCallback psMemAllocateCallbackSet(374 psMemAlloc ateCallback func///< Function to run at memory allocation of specific mem block377 * @return psMemAllocCallback old psMemAllocCallback function 378 */ 379 psMemAllocCallback psMemAllocCallbackSet( 380 psMemAllocCallback func ///< Function to run at memory allocation of specific mem block 375 381 ); 376 382 … … 398 404 psMemId psMemGetId(void); 399 405 400 /** set p_psMemAlloc ateID to specific id401 * 402 * A private variable, p_psMemAlloc ateID, can be used to trace the allocation403 * and freeing of specific memory blocks. If p_psMemAlloc ateID is set and a404 * memory block with that ID is allocated, psMemAlloc ateCallback is called406 /** set p_psMemAllocID to specific id 407 * 408 * A private variable, p_psMemAllocID, can be used to trace the allocation 409 * and freeing of specific memory blocks. If p_psMemAllocID is set and a 410 * memory block with that ID is allocated, psMemAllocCallback is called 405 411 * just before memory is returned to the calling function. 406 412 * … … 409 415 * @return psMemId 410 416 * 411 * @see psMemAlloc ateCallbackSet412 */ 413 psMemId psMemAlloc ateCallbackSetID(414 psMemId id ///< ID to set417 * @see psMemAllocCallbackSet 418 */ 419 psMemId psMemAllocCallbackSetID( 420 psMemId id ///< ID to set 415 421 ); 416 422 … … 429 435 */ 430 436 psMemId psMemFreeCallbackSetID( 431 psMemId id ///< ID to set437 psMemId id ///< ID to set 432 438 ); 433 439
Note:
See TracChangeset
for help on using the changeset viewer.
