Changeset 4162 for trunk/psLib/src/sys/psMemory.h
- Timestamp:
- Jun 8, 2005, 1:40:46 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/sys/psMemory.h (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psMemory.h
r3682 r4162 12 12 * @ingroup MemoryManagement 13 13 * 14 * @version $Revision: 1.3 6$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-0 4-07 20:27:41$14 * @version $Revision: 1.37 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-06-08 23:40:45 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 18 18 */ 19 19 20 #if !defined(PS_MEMORY_H)20 #ifndef PS_MEMORY_H 21 21 #define PS_MEMORY_H 22 22 … … 125 125 * 126 126 * @return psPtr pointer to the allocated buffer. This will not be NULL. 127 * @see psFree 127 * @see psFree 128 128 */ 129 129 #ifdef DOXYGEN 130 130 psPtr psAlloc(size_t size ///< Size required 131 131 ); 132 #else 132 #else // #ifdef DOXYGEN 133 133 psPtr p_psAlloc(size_t size, ///< Size required 134 134 const char *file, ///< File of call … … 139 139 #ifndef SWIG 140 140 #define psAlloc(size) p_psAlloc(size, __FILE__, __LINE__) 141 #endif 142 143 #endif 141 #endif // ! SWIG 142 143 #endif // ! DOXYGEN 144 144 145 145 /** Set the deallocator routine 146 146 * 147 * A deallocator routine can optionally be assigned to a memory block to 147 * A deallocator routine can optionally be assigned to a memory block to 148 148 * ensure that associated memory blocks also get freed, e.g., memory buffers 149 149 * referenced within a struct. … … 157 157 /** Get the deallocator routine 158 158 * 159 * This function returns the deallocator for a memory block. A deallocator 160 * routine can optionally be assigned to a memory block to ensure that 161 * associated memory blocks also get freed, e.g., memory buffers referenced 162 * within a struct. 159 * This function returns the deallocator for a memory block. A deallocator 160 * routine can optionally be assigned to a memory block to ensure that 161 * associated memory blocks also get freed, e.g., memory buffers referenced 162 * within a struct. 163 163 * 164 164 * @return psFreeFcn the routine to be called at deallocation. … … 170 170 /** Set the memory as persistent so that it is ignored when detecting memory leaks. 171 171 * 172 * Used to mark a memory block as persistent data within the library, 172 * Used to mark a memory block as persistent data within the library, 173 173 * i.e., non user-level data used to hold psLib's state or cache data. Such 174 174 * examples of this class of memory is psTrace's trace-levels and dynamic … … 185 185 /** Get the memory's persistent flag. 186 186 * 187 * Checks if a memory block has been marked as persistent by 187 * Checks if a memory block has been marked as persistent by 188 188 * p_psMemSetPresistent. 189 189 * … … 207 207 size_t size ///< Size required 208 208 ); 209 #else 209 #else // #ifdef DOXYGEN 210 210 psPtr p_psRealloc( 211 211 psPtr ptr, ///< Pointer to re-allocate … … 218 218 #ifndef SWIG 219 219 #define psRealloc(ptr, size) p_psRealloc(ptr, size, __FILE__, __LINE__) 220 #endif 221 222 #endif 220 #endif // ! SWIG 221 222 #endif // ! DOXYGEN 223 223 224 224 /** Free memory. This operates much like free(). … … 230 230 psPtr ptr ///< Pointer to free, if NULL, function returns immediately. 231 231 ); 232 #else 232 #else // #ifdef DOXYGEN 233 233 void p_psFree( 234 234 psPtr ptr, ///< Pointer to free … … 240 240 #ifndef SWIG 241 241 #define psFree(ptr) p_psFree(ptr, __FILE__, __LINE__) 242 #endif 243 244 #endif 242 #endif // ! SWIG 243 244 #endif // ! DOXYGEN 245 245 246 246 /** Check for memory leaks. This scans for allocated memory buffers not freed with an ID not less than id0. … … 299 299 #ifndef SWIG 300 300 #define psMemIncrRefCounter(vptr) p_psMemIncrRefCounter(vptr, __FILE__, __LINE__) 301 #endif 302 303 #endif 301 #endif // !SWIG 302 303 #endif // !DOXYGEN 304 304 305 305 /** Decrement reference counter and return the pointer … … 307 307 * @ingroup memRefCount 308 308 * 309 * @return psPtr the pointer deremented in refCount, or NULL if pointer is 309 * @return psPtr the pointer deremented in refCount, or NULL if pointer is 310 310 * fully dereferenced. 311 311 */ … … 314 314 psPtr vptr ///< Pointer to decrement refCounter, and return 315 315 ); 316 #else 316 #else // DOXYGEN 317 317 psPtr p_psMemDecrRefCounter( 318 318 psPtr vptr, ///< Pointer to decrement refCounter, and return … … 323 323 #ifndef SWIG 324 324 #define psMemDecrRefCounter(vptr) p_psMemDecrRefCounter(vptr, __FILE__, __LINE__) 325 #endif 326 327 #endif 325 #endif // !SWIG 326 327 #endif // !DOXYGEN 328 328 329 329 /** Set callback for problems. 330 330 * 331 * At various occasions, the memory manager can check the state of the memory 331 * At various occasions, the memory manager can check the state of the memory 332 332 * stack. If any of these checks discover that the memory stack is corrupted, 333 333 * the psMemProblemCallback is called. … … 343 343 /** Set callback for out-of-memory. 344 344 * 345 * If not enough memory is available to satisfy a request by psAlloc or 346 * psRealloc, these functions attempt to find an alternative solution by 347 * calling the psMemExhaustedCallback, a function which may be set by the 348 * programmer in appropriate circumstances, rather than immediately fail. 349 * The typical use of such a feature may be when a program needs a large 350 * chunk of memory to do an operation, but the exact size is not critical. 351 * This feature gives the programmer the opportunity to make a smaller 345 * If not enough memory is available to satisfy a request by psAlloc or 346 * psRealloc, these functions attempt to find an alternative solution by 347 * calling the psMemExhaustedCallback, a function which may be set by the 348 * programmer in appropriate circumstances, rather than immediately fail. 349 * The typical use of such a feature may be when a program needs a large 350 * chunk of memory to do an operation, but the exact size is not critical. 351 * This feature gives the programmer the opportunity to make a smaller 352 352 * request and try again, limiting the size of the operating buffer. 353 353 * … … 362 362 /** Set call back for when a particular memory block is allocated 363 363 * 364 * A private variable, p_psMemAllocateID, can be used to trace the allocation 365 * and freeing of specific memory blocks. If p_psMemAllocateID is set and a 366 * memory block with that ID is allocated, psMemAllocateCallback is called 364 * A private variable, p_psMemAllocateID, can be used to trace the allocation 365 * and freeing of specific memory blocks. If p_psMemAllocateID is set and a 366 * memory block with that ID is allocated, psMemAllocateCallback is called 367 367 * just before memory is returned to the calling function. 368 368 * … … 377 377 /** Set call back for when a particular memory block is freed 378 378 * 379 * A private variable, p_psMemFreeID, can be used to trace the freeing of 380 * specific memory blocks. If p_psMemFreeID is set and the memory block with 379 * A private variable, p_psMemFreeID, can be used to trace the freeing of 380 * specific memory blocks. If p_psMemFreeID is set and the memory block with 381 381 * the ID is about to be freed, the psMemFreeCallback callback is called just 382 382 * before the memory block is freed. … … 400 400 /** set p_psMemAllocateID to specific id 401 401 * 402 * A private variable, p_psMemAllocateID, can be used to trace the allocation 403 * and freeing of specific memory blocks. If p_psMemAllocateID is set and a 404 * memory block with that ID is allocated, psMemAllocateCallback is called 402 * A private variable, p_psMemAllocateID, can be used to trace the allocation 403 * and freeing of specific memory blocks. If p_psMemAllocateID is set and a 404 * memory block with that ID is allocated, psMemAllocateCallback is called 405 405 * just before memory is returned to the calling function. 406 406 * 407 407 * @ingroup memCallback 408 408 * 409 * @return psMemoryId 410 * 411 * @see psMemAllocateCallbackSet 409 * @return psMemoryId 410 * 411 * @see psMemAllocateCallbackSet 412 412 */ 413 413 psMemoryId psMemAllocateCallbackSetID( … … 417 417 /** set p_psMemFreeID to id 418 418 * 419 * A private variable, p_psMemFreeID, can be used to trace the freeing of 420 * specific memory blocks. If p_psMemFreeID is set and the memory block with 419 * A private variable, p_psMemFreeID, can be used to trace the freeing of 420 * specific memory blocks. If p_psMemFreeID is set and the memory block with 421 421 * the ID is about to be freed, the psMemFreeCallback callback is called just 422 422 * before the memory block is freed. … … 442 442 #ifdef __GNUC__ 443 443 #pragma GCC poison malloc realloc calloc free 444 #else 444 #else // __GNUC__ 445 445 #define malloc(S) _Pragma("error Use of malloc is not allowed. Use psAlloc instead.") 446 446 #define realloc(P,S) _Pragma("error Use of realloc is not allowed. Use psRealloc instead.") 447 447 #define calloc(S) _Pragma("error Use of calloc is not allowed. Use psAlloc instead.") 448 448 #define free(P) _Pragma("error Use of free is not allowed. Use psFree instead.") 449 #endif 450 #endif 451 452 #endif 453 // doxygen skip 454 455 #endif // end of header file 449 #endif // ! __GNUC__ 450 #endif // #ifndef PS_ALLOW_MALLOC 451 452 #endif // #ifndef DOXYGEN 453 454 #endif // #ifndef PS_MEMORY_H
Note:
See TracChangeset
for help on using the changeset viewer.
