IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 4, 2007, 3:15:33 PM (19 years ago)
Author:
jhoblitt
Message:

change badMemBlock() to accept file, lineno, & func
rename psMemGetRefCounter() -> p_psMemGetRefCounter()
rename psMemGetDeallocator() -> p_psMemGetDeallocator()
rename psMemSetDeallocator() -> p_psMemSetDeallocator()
add psMemGetRefCounter, psMemGetDeallocator, & psMemSetDeallocator wrapper macros
rename some function params to be more consistent with each other
remove psMemProblemCallbackSet() prototype
add file, lineno, & func to most public functions
remove redundant double free check from p_psMemDecrRefCounter

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/jch-memory/psLib/src/sys/psMemory.h

    r10902 r10906  
    1212 *  @ingroup MemoryManagement
    1313 *
    14  *  @version $Revision: 1.61.2.5 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2007-01-04 21:55:39 $
     14 *  @version $Revision: 1.61.2.6 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2007-01-05 01:15:33 $
    1616 *
    1717 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    109109typedef void (*psMemProblemCallback) (
    110110    psMemBlock* ptr,                   ///< the pointer to the problematic memory block.
    111     const char *filename,                    ///< the file in which the problem originated
     111    const char *file,                  ///< the file in which the problem originated
    112112    unsigned int lineno                ///< the line number in which the problem originated
    113113);
     
    139139psPtr p_psAlloc(
    140140    size_t size,                       ///< Size required
    141     const char *filename,              ///< File of caller
     141    const char *file,                  ///< File of caller
    142142    unsigned int lineno,               ///< Line number of caller
    143143    const char *func                   ///< Function name of caller
     
    152152#endif // ! DOXYGEN
    153153
     154
    154155/** Set the deallocator routine
    155156 *
     
    159160 *
    160161 */
     162#ifdef DOXYGEN
     163
    161164void psMemSetDeallocator(
    162165    psPtr ptr,                         ///< the memory block to operate on
    163166    psFreeFunc freeFunc                ///< the function to be executed at deallocation
    164167);
     168
     169#else // ifdef DOXYGEN
     170
     171void 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) \
     181p_psMemSetDeallocator(ptr, freeFunc, __FILE__, __LINE__, __func__);
     182#endif // ! SWIG
     183
     184#endif // ifdef DOXYGEN
     185
    165186
    166187/** Get the deallocator routine
     
    173194 *  @return psFreeFunc    the routine to be called at deallocation.
    174195 */
     196#ifdef DOXYGEN
     197
    175198psFreeFunc psMemGetDeallocator(
    176     const psPtr ptr                    ///< the memory block
    177 );
     199    const psPtr ptr                     ///< the memory block
     200);
     201
     202#else // ifdef DOXYGEN
     203
     204psFreeFunc 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) \
     213p_psMemGetDeallocator(ptr, __FILE__, __LINE__, __func__)
     214#endif // ! SWIG
     215
     216#endif // ifdef DOXYGEN
     217
    178218
    179219/** Checks the deallocator to see if the pointer matches the desired datatype.
     
    207247bool psMemGetThreadSafety(void);
    208248
     249
    209250/** Set the memory as persistent so that it is ignored when detecting memory leaks.
    210251 *
     
    217258 *
    218259 */
     260#ifdef DOXYGEN
     261
     262void 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
    219269void p_psMemSetPersistent(
    220270    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) \
     279p_psMemSetPersistent(ptr, value, __FILE__, __LINE__, __func__);
     280#endif // ! SWIG
     281
     282#endif // DOXYGEN
     283
    223284
    224285/** Set whether allocated memory is persistent
     
    229290 */
    230291bool p_psMemAllocatePersistent(bool is_persistent); ///< Should all memory allocated be persistent?
     292
    231293
    232294/** Get the memory's persistent flag.
     
    239301 *  @return bool    true if memory is marked persistent, otherwise false.
    240302 */
     303#ifdef DOXYGEN
     304
     305bool psMemGetPersistent(
     306    psPtr ptr,                         ///< the memory block to check.
     307);
     308#else // ifdef DOXYGEN
     309
    241310bool 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) \
     319p_MemGetPersistent(ptr, __FILE__, __LINE__, __func__);
     320#endif // ! SWIG
     321
     322#endif // DOXYGEN
    244323
    245324
     
    260339    psPtr ptr,                         ///< Pointer to re-allocate
    261340    size_t size,                       ///< Size required
    262     const char *filename,              ///< File of caller
     341    const char *file,                  ///< File of caller
    263342    unsigned int lineno,               ///< Line number of caller
    264343    const char *func                   ///< Function name of caller
     
    273352#endif // ! DOXYGEN
    274353
     354
    275355/** Free memory.  This operates much like free().
    276356 *
     
    285365/// Free memory.  psFree sends file and line number to p_psFree.
    286366#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) \
     368p_psMemDecrRefCounter((psPtr *)ptr, __FILE__, __LINE__, __func__);
    289369#endif // ! SWIG
    290370
    291371#endif // ! DOXYGEN
     372
    292373
    293374/** Check for memory leaks.  This scans for allocated memory buffers not freed with an ID not less than id0.
     
    330411 *  @ingroup memRefCount
    331412 */
     413#ifdef DOXYGEN
     414
    332415psReferenceCount psMemGetRefCounter(
    333416    const psPtr ptr                    ///< Pointer to get refCounter for
    334417);
    335418
     419#else // ifdef DOXYGEN
     420
     421psReferenceCount 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) \
     430p_psMemGetRefCounter(ptr, __FILE__, __LINE__, __func__)
     431#endif // !SWIG
     432
     433#endif // !DOXYGEN
     434
     435
    336436/** Increment reference counter and return the pointer
    337437 *
     
    341441 */
    342442#ifdef DOXYGEN
     443
    343444psPtr psMemIncrRefCounter(
    344445    const psPtr ptr                    ///< Pointer to increment refCounter, and return
    345446);
    346 #else
     447#else // ifdef DOXYGEN
     448
    347449psPtr p_psMemIncrRefCounter(
    348     const psPtr vptr,                  ///< Pointer to increment refCounter, and return
     450    const psPtr ptr,                  ///< Pointer to increment refCounter, and return
    349451    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) \
     458p_psMemIncrRefCounter(ptr, __FILE__, __LINE__, __func__)
    355459#endif // !SWIG
    356460
    357461#endif // !DOXYGEN
     462
    358463
    359464/** Decrement reference counter and return the pointer
     
    365470 */
    366471#ifdef DOXYGEN
     472
    367473psPtr psMemDecrRefCounter(
    368474    psPtr ptr                         ///< Pointer to decrement refCounter, and return
    369475);
     476
    370477#else // DOXYGEN
     478
    371479psPtr p_psMemDecrRefCounter(
    372     psPtr vptr,                        ///< Pointer to decrement refCounter, and return
     480    psPtr ptr,                        ///< Pointer to decrement refCounter, and return
    373481    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) \
     488p_psMemDecrRefCounter(ptr, __FILE__, __LINE__, __func__)
    379489#endif // !SWIG
    380490
     
    408518#endif // !DOXYGEN
    409519#endif // psMemSetRefCounter
    410 
    411 /** Set callback for problems.
    412  *
    413  *  At various occasions, the memory manager can check the state of the memory
    414  *  stack. If any of these checks discover that the memory stack is corrupted,
    415  *  the psMemProblemCallback is called.
    416  
    417  *  @ingroup memCallback
    418  *
    419  *  @return psMemProblemCallback       old psMemProblemCallback function
    420  */
    421 psMemProblemCallback psMemProblemCallbackSet(
    422     psMemProblemCallback func          ///< Function to run at memory problem detection
    423 );
    424520
    425521/** Set callback for out-of-memory.
Note: See TracChangeset for help on using the changeset viewer.