Changeset 10906 for branches/jch-memory/psLib/src/sys/psMemory.h
- Timestamp:
- Jan 4, 2007, 3:15:33 PM (19 years ago)
- File:
-
- 1 edited
-
branches/jch-memory/psLib/src/sys/psMemory.h (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/jch-memory/psLib/src/sys/psMemory.h
r10902 r10906 12 12 * @ingroup MemoryManagement 13 13 * 14 * @version $Revision: 1.61.2. 5$ $Name: not supported by cvs2svn $15 * @date $Date: 2007-01-0 4 21:55:39$14 * @version $Revision: 1.61.2.6 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2007-01-05 01:15:33 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 109 109 typedef void (*psMemProblemCallback) ( 110 110 psMemBlock* ptr, ///< the pointer to the problematic memory block. 111 const char *file name,///< the file in which the problem originated111 const char *file, ///< the file in which the problem originated 112 112 unsigned int lineno ///< the line number in which the problem originated 113 113 ); … … 139 139 psPtr p_psAlloc( 140 140 size_t size, ///< Size required 141 const char *file name,///< File of caller141 const char *file, ///< File of caller 142 142 unsigned int lineno, ///< Line number of caller 143 143 const char *func ///< Function name of caller … … 152 152 #endif // ! DOXYGEN 153 153 154 154 155 /** Set the deallocator routine 155 156 * … … 159 160 * 160 161 */ 162 #ifdef DOXYGEN 163 161 164 void psMemSetDeallocator( 162 165 psPtr ptr, ///< the memory block to operate on 163 166 psFreeFunc freeFunc ///< the function to be executed at deallocation 164 167 ); 168 169 #else // ifdef DOXYGEN 170 171 void p_psMemSetDeallocator( 172 psPtr ptr, ///< the memory block to operate on 173 psFreeFunc freeFunc, ///< the function to be executed at deallocation 174 const char *file, ///< File of caller 175 unsigned int lineno, ///< Line number of caller 176 const char *func ///< Function name of caller 177 ); 178 179 #ifndef SWIG 180 #define psMemSetDeallocator(ptr, freeFunc) \ 181 p_psMemSetDeallocator(ptr, freeFunc, __FILE__, __LINE__, __func__); 182 #endif // ! SWIG 183 184 #endif // ifdef DOXYGEN 185 165 186 166 187 /** Get the deallocator routine … … 173 194 * @return psFreeFunc the routine to be called at deallocation. 174 195 */ 196 #ifdef DOXYGEN 197 175 198 psFreeFunc psMemGetDeallocator( 176 const psPtr ptr ///< the memory block 177 ); 199 const psPtr ptr ///< the memory block 200 ); 201 202 #else // ifdef DOXYGEN 203 204 psFreeFunc p_psMemGetDeallocator( 205 const psPtr ptr, ///< the memory block 206 const char *file, ///< File of caller 207 unsigned int lineno, ///< Line number of caller 208 const char *func ///< Function name of caller 209 ); 210 211 #ifndef SWIG 212 #define psMemGetDeallocator(ptr) \ 213 p_psMemGetDeallocator(ptr, __FILE__, __LINE__, __func__) 214 #endif // ! SWIG 215 216 #endif // ifdef DOXYGEN 217 178 218 179 219 /** Checks the deallocator to see if the pointer matches the desired datatype. … … 207 247 bool psMemGetThreadSafety(void); 208 248 249 209 250 /** Set the memory as persistent so that it is ignored when detecting memory leaks. 210 251 * … … 217 258 * 218 259 */ 260 #ifdef DOXYGEN 261 262 void psMemSetPersistent( 263 psPtr ptr, ///< the memory block to operate on 264 bool value, ///< true if memory is persistent, otherwise false 265 ); 266 267 #else // #ifdef DOXYGEN 268 219 269 void p_psMemSetPersistent( 220 270 psPtr ptr, ///< the memory block to operate on 221 bool value ///< true if memory is persistent, otherwise false 222 ); 271 bool value, ///< true if memory is persistent, otherwise false 272 const char *file, ///< File of caller 273 unsigned int lineno, ///< Line number of caller 274 const char *func ///< Function name of caller 275 ); 276 277 #ifndef SWIG 278 #define psMemSetPersistent(ptr, value) \ 279 p_psMemSetPersistent(ptr, value, __FILE__, __LINE__, __func__); 280 #endif // ! SWIG 281 282 #endif // DOXYGEN 283 223 284 224 285 /** Set whether allocated memory is persistent … … 229 290 */ 230 291 bool p_psMemAllocatePersistent(bool is_persistent); ///< Should all memory allocated be persistent? 292 231 293 232 294 /** Get the memory's persistent flag. … … 239 301 * @return bool true if memory is marked persistent, otherwise false. 240 302 */ 303 #ifdef DOXYGEN 304 305 bool psMemGetPersistent( 306 psPtr ptr, ///< the memory block to check. 307 ); 308 #else // ifdef DOXYGEN 309 241 310 bool p_psMemGetPersistent( 242 psPtr ptr ///< the memory block to check. 243 ); 311 psPtr ptr, ///< the memory block to check. 312 const char *file, ///< File of caller 313 unsigned int lineno, ///< Line number of caller 314 const char *func ///< Function name of caller 315 ); 316 317 #ifndef SWIG 318 #define psMemGetPersistent(ptr) \ 319 p_MemGetPersistent(ptr, __FILE__, __LINE__, __func__); 320 #endif // ! SWIG 321 322 #endif // DOXYGEN 244 323 245 324 … … 260 339 psPtr ptr, ///< Pointer to re-allocate 261 340 size_t size, ///< Size required 262 const char *file name,///< File of caller341 const char *file, ///< File of caller 263 342 unsigned int lineno, ///< Line number of caller 264 343 const char *func ///< Function name of caller … … 273 352 #endif // ! DOXYGEN 274 353 354 275 355 /** Free memory. This operates much like free(). 276 356 * … … 285 365 /// Free memory. psFree sends file and line number to p_psFree. 286 366 #ifndef SWIG 287 //#define psFree(ptr) { p_psMemDecrRefCounter((psPtr)ptr, __FILE__, __LINE__); *(void**)&(ptr) = NULL; } 288 #define psFree(ptr) { p_psMemDecrRefCounter((psPtr)ptr, __FILE__, __LINE__); } 367 #define psFree(ptr) \ 368 p_psMemDecrRefCounter((psPtr *)ptr, __FILE__, __LINE__, __func__); 289 369 #endif // ! SWIG 290 370 291 371 #endif // ! DOXYGEN 372 292 373 293 374 /** Check for memory leaks. This scans for allocated memory buffers not freed with an ID not less than id0. … … 330 411 * @ingroup memRefCount 331 412 */ 413 #ifdef DOXYGEN 414 332 415 psReferenceCount psMemGetRefCounter( 333 416 const psPtr ptr ///< Pointer to get refCounter for 334 417 ); 335 418 419 #else // ifdef DOXYGEN 420 421 psReferenceCount p_psMemGetRefCounter( 422 const psPtr ptr, ///< Pointer to get refCounter for 423 const char *file, ///< File of call 424 unsigned int lineno, ///< Line number of call 425 const char *func ///< Function name of caller 426 ); 427 428 #ifndef SWIG 429 #define psMemGetRefCounter(ptr) \ 430 p_psMemGetRefCounter(ptr, __FILE__, __LINE__, __func__) 431 #endif // !SWIG 432 433 #endif // !DOXYGEN 434 435 336 436 /** Increment reference counter and return the pointer 337 437 * … … 341 441 */ 342 442 #ifdef DOXYGEN 443 343 444 psPtr psMemIncrRefCounter( 344 445 const psPtr ptr ///< Pointer to increment refCounter, and return 345 446 ); 346 #else 447 #else // ifdef DOXYGEN 448 347 449 psPtr p_psMemIncrRefCounter( 348 const psPtr vptr, ///< Pointer to increment refCounter, and return450 const psPtr ptr, ///< Pointer to increment refCounter, and return 349 451 const char *file, ///< File of call 350 psS32 lineno ///< Line number of call 351 ); 352 353 #ifndef SWIG 354 #define psMemIncrRefCounter(vptr) p_psMemIncrRefCounter(vptr, __FILE__, __LINE__) 452 unsigned int lineno, ///< Line number of call 453 const char *func ///< Function name of caller 454 ); 455 456 #ifndef SWIG 457 #define psMemIncrRefCounter(ptr) \ 458 p_psMemIncrRefCounter(ptr, __FILE__, __LINE__, __func__) 355 459 #endif // !SWIG 356 460 357 461 #endif // !DOXYGEN 462 358 463 359 464 /** Decrement reference counter and return the pointer … … 365 470 */ 366 471 #ifdef DOXYGEN 472 367 473 psPtr psMemDecrRefCounter( 368 474 psPtr ptr ///< Pointer to decrement refCounter, and return 369 475 ); 476 370 477 #else // DOXYGEN 478 371 479 psPtr p_psMemDecrRefCounter( 372 psPtr vptr, ///< Pointer to decrement refCounter, and return480 psPtr ptr, ///< Pointer to decrement refCounter, and return 373 481 const char *file, ///< File of call 374 psS32 lineno ///< Line number of call 375 ); 376 377 #ifndef SWIG 378 #define psMemDecrRefCounter(vptr) p_psMemDecrRefCounter(vptr, __FILE__, __LINE__) 482 unsigned int lineno, ///< Line number of call 483 const char *func ///< Function name of caller 484 ); 485 486 #ifndef SWIG 487 #define psMemDecrRefCounter(ptr) \ 488 p_psMemDecrRefCounter(ptr, __FILE__, __LINE__, __func__) 379 489 #endif // !SWIG 380 490 … … 408 518 #endif // !DOXYGEN 409 519 #endif // psMemSetRefCounter 410 411 /** Set callback for problems.412 *413 * At various occasions, the memory manager can check the state of the memory414 * stack. If any of these checks discover that the memory stack is corrupted,415 * the psMemProblemCallback is called.416 417 * @ingroup memCallback418 *419 * @return psMemProblemCallback old psMemProblemCallback function420 */421 psMemProblemCallback psMemProblemCallbackSet(422 psMemProblemCallback func ///< Function to run at memory problem detection423 );424 520 425 521 /** Set callback for out-of-memory.
Note:
See TracChangeset
for help on using the changeset viewer.
