Changeset 2204 for trunk/psLib/src/sys/psMemory.h
- Timestamp:
- Oct 26, 2004, 2:57:34 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/sys/psMemory.h (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psMemory.h
r1810 r2204 12 12 * @ingroup MemoryManagement 13 13 * 14 * @version $Revision: 1.3 0$ $Name: not supported by cvs2svn $15 * @date $Date: 2004- 09-14 23:48:25$14 * @version $Revision: 1.31 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-10-27 00:57:31 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 22 22 23 23 #include <stdio.h> // needed for FILE 24 #include <stdbool.h>25 24 #include <pthread.h> // we need a mutex to make this stuff thread safe. 25 26 #include "psType.h" 26 27 27 28 /** @addtogroup MemoryManagement … … 48 49 49 50 /// typedef for memory identification numbers. Guaranteed to be some variety of integer. 50 typedef unsigned longpsMemoryId;51 typedef psU64 psMemoryId; 51 52 52 53 /// typedef for a memory block's reference count. Guaranteed to be some variety of integer. 53 typedef unsigned longpsReferenceCount;54 typedef psU64 psReferenceCount; 54 55 55 56 /// typedef for deallocator. 56 typedef void (*psFreeFcn) ( void *ptr);57 typedef void (*psFreeFcn) (psPtr ptr); 57 58 58 59 /** Book-keeping data for storage allocator. … … 63 64 typedef struct psMemBlock 64 65 { 65 const void *startblock; ///< initialised to p_psMEMMAGIC66 const psPtr startblock; ///< initialised to p_psMEMMAGIC 66 67 struct psMemBlock* previousBlock; ///< previous block in allocation list 67 68 struct psMemBlock* nextBlock; ///< next block allocation list … … 70 71 const psMemoryId id; ///< a unique ID for this allocation 71 72 const char *file; ///< set from __FILE__ in e.g. p_psAlloc 72 const intlineno; ///< set from __LINE__ in e.g. p_psAlloc73 const psS32 lineno; ///< set from __LINE__ in e.g. p_psAlloc 73 74 pthread_mutex_t refCounterMutex; ///< mutex to ensure exclusive access to reference counter 74 75 psReferenceCount refCounter; ///< how many times pointer is referenced 75 bool persistent; ///< marks if this non-user persistent data like error stack, etc.76 const void *endblock; ///< initialised to p_psMEMMAGIC76 psBool persistent; ///< marks if this non-user persistent data like error stack, etc. 77 const psPtr endblock; ///< initialised to p_psMEMMAGIC 77 78 } 78 79 psMemBlock; … … 106 107 const psMemBlock* ptr, ///< the pointer to the problematic memory block. 107 108 const char *file, ///< the file in which the problem originated 108 intlineno ///< the line number in which the problem originated109 psS32 lineno ///< the line number in which the problem originated 109 110 ); 110 111 111 112 /** prototype of a callback function used when memory runs out 112 113 * 113 * @return void*pointer to requested buffer of the size size_t, or NULL if memory could not114 * @return psPtr pointer to requested buffer of the size size_t, or NULL if memory could not 114 115 * be found. 115 116 * … … 117 118 * @ingroup memCallback 118 119 */ 119 typedef void *(*psMemExhaustedCallback) (120 typedef psPtr (*psMemExhaustedCallback) ( 120 121 size_t size ///< the size of buffer required 121 122 ); … … 123 124 /** Memory allocation. This operates much like malloc(), but is guaranteed to return a non-NULL value. 124 125 * 125 * @return void*pointer to the allocated buffer. This will not be NULL.126 * @return psPtr pointer to the allocated buffer. This will not be NULL. 126 127 * @see psFree 127 128 */ 128 129 #ifdef DOXYGEN 129 void *psAlloc(size_t size ///< Size required130 psPtr psAlloc(size_t size ///< Size required 130 131 ); 131 132 #else 132 133 133 void *p_psAlloc(size_t size, ///< Size required134 psPtr p_psAlloc(size_t size, ///< Size required 134 135 const char *file, ///< File of call 135 intlineno ///< Line number of call136 psS32 lineno ///< Line number of call 136 137 ); 137 138 … … 148 149 */ 149 150 void p_psMemSetDeallocator( 150 void *ptr, ///< the memory block to operate on151 psPtr ptr, ///< the memory block to operate on 151 152 psFreeFcn freeFcn ///< the function to be executed at deallocation 152 153 ); … … 162 163 */ 163 164 psFreeFcn p_psMemGetDeallocator( 164 void *ptr ///< the memory block165 psPtr ptr ///< the memory block 165 166 ); 166 167 … … 176 177 */ 177 178 void p_psMemSetPersistent( 178 void *ptr, ///< the memory block to operate on179 bool value ///< true if memory is persistent, otherwise false179 psPtr ptr, ///< the memory block to operate on 180 psBool value ///< true if memory is persistent, otherwise false 180 181 ); 181 182 … … 187 188 * Memory marked as persistent is excluded from memory leak checks. 188 189 * 189 * @return bool true if memory is marked persistent, otherwise false.190 */ 191 bool p_psMemGetPersistent(192 void *ptr ///< the memory block to check.190 * @return psBool true if memory is marked persistent, otherwise false. 191 */ 192 psBool p_psMemGetPersistent( 193 psPtr ptr ///< the memory block to check. 193 194 ); 194 195 … … 196 197 /** Memory re-allocation. This operates much like realloc(), but is guaranteed to return a non-NULL value. 197 198 * 198 * @return void*pointer to resized buffer. This will not be NULL.199 * @return psPtr pointer to resized buffer. This will not be NULL. 199 200 * @see psAlloc, psFree 200 201 */ 201 202 #ifdef DOXYGEN 202 void *psRealloc(203 void *ptr ///< Pointer to re-allocate203 psPtr psRealloc( 204 psPtr ptr ///< Pointer to re-allocate 204 205 size_t size, ///< Size required 205 206 ); 206 207 #else 207 208 208 void *p_psRealloc(209 void *ptr, ///< Pointer to re-allocate209 psPtr p_psRealloc( 210 psPtr ptr, ///< Pointer to re-allocate 210 211 size_t size, ///< Size required 211 212 const char *file, ///< File of call 212 intlineno ///< Line number of call213 psS32 lineno ///< Line number of call 213 214 ); 214 215 … … 224 225 #ifdef DOXYGEN 225 226 void psFree( 226 void *ptr, ///< Pointer to free, if NULL, function returns immediately.227 psPtr ptr, ///< Pointer to free, if NULL, function returns immediately. 227 228 ); 228 229 #else 229 230 230 231 void p_psFree( 231 void *ptr, ///< Pointer to free232 psPtr ptr, ///< Pointer to free 232 233 const char *file, ///< File of call 233 intlineno ///< Line number of call234 psS32 lineno ///< Line number of call 234 235 ); 235 236 … … 248 249 * If memory leaks are found, the Memory Problem callback will be called as well. 249 250 * 250 * return intnumber of memory blocks found as 'leaks', i.e., the number of currently allocated memory251 * return psS32 number of memory blocks found as 'leaks', i.e., the number of currently allocated memory 251 252 * blocks above id0 that have not been freed. 252 253 * @see psAlloc, psFree, psgetMemId, psMemProblemCallbackSet 253 254 * @ingroup memTracing 254 255 */ 255 intpsMemCheckLeaks(256 psS32 psMemCheckLeaks( 256 257 psMemoryId id0, ///< don't list blocks with id < id0 257 258 psMemBlock* ** arr, ///< pointer to array of pointers to leaked blocks, or NULL … … 264 265 * @ingroup memTracing 265 266 */ 266 intpsMemCheckCorruption(267 bool abort_on_error ///< Abort on detecting corruption?267 psS32 psMemCheckCorruption( 268 psBool abort_on_error ///< Abort on detecting corruption? 268 269 ); 269 270 … … 273 274 */ 274 275 psReferenceCount psMemGetRefCounter( 275 void *vptr ///< Pointer to get refCounter for276 psPtr vptr ///< Pointer to get refCounter for 276 277 ); 277 278 … … 281 282 */ 282 283 #ifdef DOXYGEN 283 void *psMemIncrRefCounter(284 void *vptr ///< Pointer to increment refCounter, and return285 ); 286 #else 287 288 void *p_psMemIncrRefCounter(289 void *vptr, ///< Pointer to increment refCounter, and return284 psPtr psMemIncrRefCounter( 285 psPtr vptr ///< Pointer to increment refCounter, and return 286 ); 287 #else 288 289 psPtr p_psMemIncrRefCounter( 290 psPtr vptr, ///< Pointer to increment refCounter, and return 290 291 const char *file, ///< File of call 291 intlineno ///< Line number of call292 psS32 lineno ///< Line number of call 292 293 ); 293 294 … … 299 300 * @ingroup memRefCount 300 301 * 301 * @return void*the pointer deremented in refCount, or NULL if pointer is302 * @return psPtr the pointer deremented in refCount, or NULL if pointer is 302 303 * fully dereferenced. 303 304 */ 304 305 #ifdef DOXYGEN 305 void*psMemDecrRefCounter(306 void*vptr ///< Pointer to decrement refCounter, and return307 ); 308 #else 309 310 void *p_psMemDecrRefCounter(311 void *vptr, ///< Pointer to decrement refCounter, and return306 psPtr psMemDecrRefCounter( 307 psPtr vptr ///< Pointer to decrement refCounter, and return 308 ); 309 #else 310 311 psPtr p_psMemDecrRefCounter( 312 psPtr vptr, ///< Pointer to decrement refCounter, and return 312 313 const char *file, ///< File of call 313 intlineno ///< Line number of call314 psS32 lineno ///< Line number of call 314 315 ); 315 316
Note:
See TracChangeset
for help on using the changeset viewer.
