Changeset 11672 for trunk/psLib/src/sys/psMemory.h
- Timestamp:
- Feb 6, 2007, 2:36:02 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/sys/psMemory.h (modified) (25 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psMemory.h
r11416 r11672 15 15 * @ingroup MemoryManagement 16 16 * 17 * @version $Revision: 1.6 5$ $Name: not supported by cvs2svn $18 * @date $Date: 2007-0 1-30 03:00:50$17 * @version $Revision: 1.66 $ $Name: not supported by cvs2svn $ 18 * @date $Date: 2007-02-07 00:36:02 $ 19 19 * 20 20 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 27 27 /// @{ 28 28 29 #include <stdio.h> // needed for FILE 30 #include <pthread.h> // we need a mutex to make this stuff thread safe. 31 #include "psType.h" 29 #include <stdio.h> // needed for FILE 30 #include <pthread.h> // we need a mutex to make this stuff thread safe. 31 #include <stdint.h> // for uint32_t 32 #include <stdbool.h> 32 33 33 34 /** @addtogroup MemoryManagement … … 35 36 */ 36 37 37 #define P_PS_MEMMAGIC ( psU32)0xdeadbeef // Magic number in psMemBlock header38 #define P_PS_MEMMAGIC (uint32_t)0xdeadbeef // Magic number in psMemBlock header 38 39 39 40 /// typedef for memory identification numbers. Guaranteed to be some variety of integer. … … 44 45 45 46 /// typedef for deallocator. 46 typedef void (*psFreeFunc) (void *ptr);47 typedef void (*psFreeFunc) (void *ptr); 47 48 48 49 /** Book-keeping data for storage allocator. … … 57 58 typedef struct psMemBlock 58 59 { 59 const psU32startblock; ///< initialised to p_psMEMMAGIC60 const uint32_t startblock; ///< initialised to p_psMEMMAGIC 60 61 struct psMemBlock* previousBlock; ///< previous block in allocation list 61 62 struct psMemBlock* nextBlock; ///< next block allocation list … … 75 76 psReferenceCount refCounter; ///< how many times pointer is referenced 76 77 bool persistent; ///< marks if this non-user persistent data like error stack, etc. 77 const psU32endblock; ///< initialised to p_psMEMMAGIC78 const uint32_t endblock; ///< initialised to p_psMEMMAGIC 78 79 } 79 80 psMemBlock; … … 109 110 /** prototype of a callback function used when memory runs out 110 111 * 111 * @return psPtrpointer to requested buffer of the size size_t, or NULL if memory could not112 * @return void * pointer to requested buffer of the size size_t, or NULL if memory could not 112 113 * be found. 113 114 * 114 115 * @see psMemExhaustedCallbackSet 115 116 */ 116 typedef psPtr(*psMemExhaustedCallback) (117 typedef void *(*psMemExhaustedCallback) ( 117 118 size_t size ///< the size of buffer required 118 119 ); … … 120 121 /** Memory allocation. This operates much like malloc(), but is guaranteed to return a non-NULL value. 121 122 * 122 * @return psPtrpointer to the allocated buffer. This will not be NULL.123 * @return void * pointer to the allocated buffer. This will not be NULL. 123 124 * @see psFree 124 125 */ 125 126 #ifdef DOXYGEN 126 127 127 psPtrpsAlloc(128 void *psAlloc( 128 129 size_t size ///< Size required 129 130 ); … … 132 133 133 134 #ifdef __GNUC__ 134 psPtrp_psAlloc(135 void *p_psAlloc( 135 136 size_t size, ///< Size required 136 137 const char *file, ///< File of caller … … 139 140 ) __attribute__((malloc)); 140 141 # else // __GNUC__ 141 142 psPtr p_psAlloc( 142 void *p_psAlloc( 143 143 size_t size, ///< Size required 144 144 const char *file, ///< File of caller … … 167 167 168 168 void psMemSetDeallocator( 169 psPtrptr, ///< the memory block to operate on169 void *ptr, ///< the memory block to operate on 170 170 psFreeFunc freeFunc ///< the function to be executed at deallocation 171 171 ); … … 174 174 175 175 void p_psMemSetDeallocator( 176 psPtrptr, ///< the memory block to operate on176 void *ptr, ///< the memory block to operate on 177 177 psFreeFunc freeFunc, ///< the function to be executed at deallocation 178 178 const char *file, ///< File of caller … … 201 201 202 202 psFreeFunc psMemGetDeallocator( 203 const psPtrptr ///< the memory block203 void *ptr ///< the memory block 204 204 ); 205 205 … … 207 207 208 208 psFreeFunc p_psMemGetDeallocator( 209 const psPtrptr, ///< the memory block209 void *ptr, ///< the memory block 210 210 const char *file, ///< File of caller 211 211 unsigned int lineno, ///< Line number of caller … … 256 256 257 257 void psMemSetPersistent( 258 psPtr ptr,///< the memory block to operate on259 bool value, ///< true if memory is persistent, otherwise false258 void *ptr, ///< the memory block to operate on 259 bool value, ///< true if memory is persistent, otherwise false 260 260 ); 261 261 … … 263 263 264 264 void p_psMemSetPersistent( 265 psPtr ptr,///< the memory block to operate on266 bool value, ///< true if memory is persistent, otherwise false267 const char *file, ///< File of caller268 unsigned int lineno, ///< Line number of caller269 const char *func ///< Function name of caller265 void *ptr, ///< the memory block to operate on 266 bool value, ///< true if memory is persistent, otherwise false 267 const char *file, ///< File of caller 268 unsigned int lineno, ///< Line number of caller 269 const char *func ///< Function name of caller 270 270 ); 271 271 … … 299 299 300 300 bool psMemGetPersistent( 301 psPtr ptr,///< the memory block to check.301 void *ptr, ///< the memory block to check. 302 302 ); 303 303 #else // ifdef DOXYGEN 304 304 305 305 bool p_psMemGetPersistent( 306 psPtr ptr,///< the memory block to check.307 const char *file, ///< File of caller308 unsigned int lineno, ///< Line number of caller309 const char *func ///< Function name of caller306 void *ptr, ///< the memory block to check. 307 const char *file, ///< File of caller 308 unsigned int lineno, ///< Line number of caller 309 const char *func ///< Function name of caller 310 310 ); 311 311 … … 320 320 /** Memory re-allocation. This operates much like realloc(), but is guaranteed to return a non-NULL value. 321 321 * 322 * @return psPtrpointer to resized buffer. This will not be NULL.322 * @return void * pointer to resized buffer. This will not be NULL. 323 323 * @see psAlloc, psFree 324 324 */ 325 325 #ifdef DOXYGEN 326 326 327 psPtrpsRealloc(328 psPtr ptr,///< Pointer to re-allocate329 size_t size ///< Size required327 void *psRealloc( 328 void *ptr, ///< Pointer to re-allocate 329 size_t size ///< Size required 330 330 ); 331 331 #else // #ifdef DOXYGEN 332 333 332 #ifdef __GNUC__ 334 psPtrp_psRealloc(335 psPtr ptr,///< Pointer to re-allocate336 size_t size, ///< Size required337 const char *file, ///< File of caller338 unsigned int lineno, ///< Line number of caller339 const char *func ///< Function name of caller333 void *p_psRealloc( 334 void *ptr, ///< Pointer to re-allocate 335 size_t size, ///< Size required 336 const char *file, ///< File of caller 337 unsigned int lineno, ///< Line number of caller 338 const char *func ///< Function name of caller 340 339 ) __attribute__((malloc)); 341 340 # else // __GNUC__ 342 343 psPtr p_psRealloc( 344 psPtr ptr, ///< Pointer to re-allocate 345 size_t size, ///< Size required 346 const char *file, ///< File of caller 347 unsigned int lineno, ///< Line number of caller 348 const char *func ///< Function name of caller 341 void *p_psRealloc( 342 void *ptr, ///< Pointer to re-allocate 343 size_t size, ///< Size required 344 const char *file, ///< File of caller 345 unsigned int lineno, ///< Line number of caller 346 const char *func ///< Function name of caller 349 347 ); 350 348 #endif // __GNUC__ … … 365 363 #ifdef DOXYGEN 366 364 void psFree( 367 psPtr ptr///< Pointer to free, if NULL, function returns immediately.365 void *ptr ///< Pointer to free, if NULL, function returns immediately. 368 366 ); 369 367 #else // #ifdef DOXYGEN … … 372 370 #ifndef SWIG 373 371 #define psFree(ptr) \ 374 p_psMemDecrRefCounter(( psPtr*)ptr, __FILE__, __LINE__, __func__);372 p_psMemDecrRefCounter((void **)ptr, __FILE__, __LINE__, __func__); 375 373 #endif // ! SWIG 376 374 … … 449 447 450 448 psReferenceCount psMemGetRefCounter( 451 const psPtr ptr///< Pointer to get refCounter for449 void *ptr ///< Pointer to get refCounter for 452 450 ); 453 451 … … 455 453 456 454 psReferenceCount p_psMemGetRefCounter( 457 const psPtr ptr,///< Pointer to get refCounter for458 const char *file, ///< File of call459 unsigned int lineno, ///< Line number of call460 const char *func ///< Function name of caller455 void *ptr, ///< Pointer to get refCounter for 456 const char *file, ///< File of call 457 unsigned int lineno, ///< Line number of call 458 const char *func ///< Function name of caller 461 459 ); 462 460 … … 471 469 /** Increment reference counter and return the pointer 472 470 * 473 * @return psPtr474 * 475 */ 476 #ifdef DOXYGEN 477 478 psPtrpsMemIncrRefCounter(479 const psPtr ptr///< Pointer to increment refCounter, and return471 * @return void * 472 * 473 */ 474 #ifdef DOXYGEN 475 476 void *psMemIncrRefCounter( 477 void *ptr ///< Pointer to increment refCounter, and return 480 478 ); 481 479 #else // ifdef DOXYGEN 482 480 483 psPtrp_psMemIncrRefCounter(484 const psPtr ptr,///< Pointer to increment refCounter, and return485 const char *file, ///< File of call486 unsigned int lineno, ///< Line number of call487 const char *func ///< Function name of caller481 void *p_psMemIncrRefCounter( 482 void *ptr, ///< Pointer to increment refCounter, and return 483 const char *file, ///< File of call 484 unsigned int lineno, ///< Line number of call 485 const char *func ///< Function name of caller 488 486 ); 489 487 … … 499 497 * 500 498 * 501 * @return psPtrthe pointer deremented in refCount, or NULL if pointer is499 * @return void * the pointer deremented in refCount, or NULL if pointer is 502 500 * fully dereferenced. 503 501 */ 504 502 #ifdef DOXYGEN 505 503 506 psPtrpsMemDecrRefCounter(507 psPtr ptr///< Pointer to decrement refCounter, and return504 void *psMemDecrRefCounter( 505 void *ptr ///< Pointer to decrement refCounter, and return 508 506 ); 509 507 510 508 #else // DOXYGEN 511 509 512 psPtrp_psMemDecrRefCounter(513 psPtr ptr,///< Pointer to decrement refCounter, and return514 const char *file, ///< File of call515 unsigned int lineno, ///< Line number of call516 const char *func ///< Function name of caller510 void *p_psMemDecrRefCounter( 511 void *ptr, ///< Pointer to decrement refCounter, and return 512 const char *file, ///< File of call 513 unsigned int lineno, ///< Line number of call 514 const char *func ///< Function name of caller 517 515 ); 518 516 … … 527 525 /** Set reference counter and return the pointer 528 526 * 529 * @return psPtrthe pointer with refCount set, or NULL if pointer is527 * @return void * the pointer with refCount set, or NULL if pointer is 530 528 * fully dereferenced. 531 529 */ 532 530 #ifdef DOXYGEN 533 psPtrpsMemSetRefCounter(534 psPtrptr, ///< Pointer to decrement refCounter, and return531 void * psMemSetRefCounter( 532 void * ptr, ///< Pointer to decrement refCounter, and return 535 533 psReferenceCount count ///< New reference count 536 534 ); 537 535 #else // DOXYGEN 538 psPtrp_psMemSetRefCounter(539 psPtrvptr, ///< Pointer to decrement refCounter, and return536 void * p_psMemSetRefCounter( 537 void * vptr, ///< Pointer to decrement refCounter, and return 540 538 psReferenceCount count, ///< New reference count 541 539 const char *file, ///< File of call
Note:
See TracChangeset
for help on using the changeset viewer.
