IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1569


Ignore:
Timestamp:
Aug 18, 2004, 3:08:06 PM (22 years ago)
Author:
Paul Price
Message:

Updating from SDRS, and also changing the "long id" parameters to
psMemoryId and psReferenceCount, as appropriate, in order to maintain
consitency.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/archive/pslib/include/psMemory.h

    r753 r1569  
    1010// Structures ***********************************************************
    1111
     12/** A function that frees an allocated pointer */
     13typedef void (*psFreeFcn)(void* ptr);
     14
     15/** Memory ID number */
     16typedef unsigned long psMemoryId;
     17
     18/** Reference counter number */
     19typedef unsigned long psReferenceCount;
     20
    1221/** Book-keeping data for storage allocator.
    1322 *  N.b. sizeof(psMemBlock) must be chosen such that if ptr is a pointer
     
    1625 */
    1726typedef struct {
    18     const void *startblock;             ///< initialised to p_psMEMMAGIC
    19     const unsigned long id;             ///< a unique ID for this allocation
    20     const char *file;                   ///< set from __FILE__ in e.g. p_psAlloc
    21     const int lineno;                   ///< set from __LINE__ in e.g. p_psAlloc
    22     int refCounter;                     ///< how many times pointer is referenced
    23     const void **endpost;               ///< initialised to p_psMEMMAGIC
    24     const void *endblock;               ///< initialised to p_psMEMMAGIC
     27    const void* startblock;             ///< initialised to p_psMEMMAGIC
     28    struct psMemBlock* previousBlock;   ///< previous block in allocation list
     29    struct psMemBlock* nextBlock;       ///< next block allocation list
     30    psFreeFcn freeFcn;                  ///< deallocator.  If NULL, use generic deallocation.
     31    size_t  userMemorySize;             ///< the size of the user-portion of the memory block
     32    const psMemoryId id;                ///< a unique ID for this allocation
     33    const char* file;                   ///< set from __FILE__ in e.g. p_psAlloc
     34    const int lineno;                   ///< set from __LINE__ in e.g. p_psAlloc
     35    pthread_mutex_t   refCounterMutex;  ///< mutex to ensure exclusive access to reference counter
     36    psReferenceCount refCounter;        ///< how many times pointer is referenced
     37    const void* endblock;               ///< initialised to p_psMEMMAGIC
    2538} psMemBlock;
    2639
    2740/// prototype of a basic callback used by memory functions
    28 typedef long (*psMemAllocateCallback)(const psMemBlock *ptr);
     41typedef psMemoryId (*psMemAllocateCallback)(const psMemBlock *ptr);
    2942
    3043/// prototype of memory free callback used by memory functions
    31 typedef long (*psMemFreeCallback)(const psMemBlock *ptr);
     44typedef psMemoryId (*psMemFreeCallback)(const psMemBlock *ptr);
    3245
    3346/// prototype of a callback used in error conditions
     
    4154 *  \{
    4255 */
     56
     57/** Set the fcn pointer to the appropriate ps*Free function.  If NULL, then a generic free functionality is
     58 * used (i.e., the old psFree functionality).
     59 */
     60void p_psMemSetDeallocator(void* ptr, psFreeFcn func);
     61
     62/** retrieves the function pointer to the higher-level free function to be used.  If NULL, then the
     63 * traditional psFree functionality shall be used.
     64 */
     65freeFcn p_psMemGetDeallocator(void* ptr);
    4366
    4467/// Memory allocation. Underlying private function called by macro psAlloc.
     
    6285
    6386/// Check for memory leaks
    64 int psMemCheckLeaks(int id0,            ///< don't list blocks with id < id0
     87int psMemCheckLeaks(psMemoryId id0,     ///< don't list blocks with id < id0
    6588                    psMemBlock ***arr,  ///< pointer to array of pointers to leaked blocks, or NULL
    6689                    FILE *fd)           ///< print list of leaks to fd (or NULL)
     
    6891
    6992/// Check for memory corruption
    70 int psMemCheckCorruption(int abort_on_error) ///< Abort on detecting corruption?
     93int psMemCheckCorruption(bool abort_on_error) ///< Abort on detecting corruption?
    7194;
    7295
    7396/// Return reference counter
    74 int psMemGetRefCounter(void *vptr)      ///< Pointer to get refCounter for
     97psReferenceCount psMemGetRefCounter(void *vptr) ///< Pointer to get refCounter for
    7598;
    7699
     
    99122;
    100123
     124/** Default callback functions */
     125psMemExhaustedCallback psMemExhaustedCallbackDefault;
     126psMemProblemCallback psMemProblemCallbackDefault;
     127psMemAllocateCallback psMemAllocateCallbackDefault;
     128psMemFreeCallback psMemFreeCallbackDefault;
     129
    101130/// get next memory ID
    102 int psMemGetId(void)
     131psMemoryId psMemGetId(void)
    103132;
    104133
    105134/// set p_psMemAllocateID to id
    106 long psMemAllocateIDSet(long id)        ///< ID to set
     135psMemoryId psMemAllocateCallbackSetID(psMemoryId id) ///< ID to set
    107136;
    108137
    109138/// set p_psMemFreeID to id
    110 long psMemFreeIDSet(long id)            ///< ID to set
     139psMemoryId psMemFreeCallbackSetID(psMemoryId id) ///< ID to set
    111140;
    112141
Note: See TracChangeset for help on using the changeset viewer.