IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 26, 2004, 2:57:34 PM (22 years ago)
Author:
desonia
Message:

converted native C types to ps Types, where practical.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/sys/psMemory.h

    r1810 r2204  
    1212 *  @ingroup MemoryManagement
    1313 *
    14  *  @version $Revision: 1.30 $ $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 $
    1616 *
    1717 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2222
    2323#include <stdio.h>                     // needed for FILE
    24 #include <stdbool.h>
    2524#include <pthread.h>                   // we need a mutex to make this stuff thread safe.
     25
     26#include "psType.h"
    2627
    2728/** @addtogroup MemoryManagement
     
    4849
    4950/// typedef for memory identification numbers.  Guaranteed to be some variety of integer.
    50 typedef unsigned long psMemoryId;
     51typedef psU64 psMemoryId;
    5152
    5253/// typedef for a memory block's reference count. Guaranteed to be some variety of integer.
    53 typedef unsigned long psReferenceCount;
     54typedef psU64 psReferenceCount;
    5455
    5556/// typedef for deallocator.
    56 typedef void (*psFreeFcn) (void *ptr);
     57typedef void (*psFreeFcn) (psPtr ptr);
    5758
    5859/** Book-keeping data for storage allocator.
     
    6364typedef struct psMemBlock
    6465{
    65     const void *startblock;            ///< initialised to p_psMEMMAGIC
     66    const psPtr startblock;            ///< initialised to p_psMEMMAGIC
    6667    struct psMemBlock* previousBlock;  ///< previous block in allocation list
    6768    struct psMemBlock* nextBlock;      ///< next block allocation list
     
    7071    const psMemoryId id;               ///< a unique ID for this allocation
    7172    const char *file;                  ///< set from __FILE__ in e.g. p_psAlloc
    72     const int lineno;                  ///< set from __LINE__ in e.g. p_psAlloc
     73    const psS32 lineno;                  ///< set from __LINE__ in e.g. p_psAlloc
    7374    pthread_mutex_t refCounterMutex;   ///< mutex to ensure exclusive access to reference counter
    7475    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_psMEMMAGIC
     76    psBool persistent;                   ///< marks if this non-user persistent data like error stack, etc.
     77    const psPtr endblock;              ///< initialised to p_psMEMMAGIC
    7778}
    7879psMemBlock;
     
    106107    const psMemBlock* ptr,             ///< the pointer to the problematic memory block.
    107108    const char *file,                  ///< the file in which the problem originated
    108     int lineno                         ///< the line number in which the problem originated
     109    psS32 lineno                         ///< the line number in which the problem originated
    109110);
    110111
    111112/** prototype of a callback function used when memory runs out
    112113 *
    113  *  @return void* pointer to requested buffer of the size size_t, or NULL if memory could not
     114 *  @return psPtr pointer to requested buffer of the size size_t, or NULL if memory could not
    114115 *          be found.
    115116 *
     
    117118 *  @ingroup memCallback
    118119 */
    119 typedef void *(*psMemExhaustedCallback) (
     120typedef psPtr (*psMemExhaustedCallback) (
    120121    size_t size                        ///< the size of buffer required
    121122);
     
    123124/** Memory allocation.  This operates much like malloc(), but is guaranteed to return a non-NULL value.
    124125 *
    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.
    126127 *  @see psFree
    127128 */
    128129#ifdef DOXYGEN
    129 void *psAlloc(size_t size       ///< Size required
     130psPtr psAlloc(size_t size       ///< Size required
    130131             );
    131132#else
    132133
    133 void *p_psAlloc(size_t size,    ///< Size required
     134psPtr p_psAlloc(size_t size,    ///< Size required
    134135                const char *file,       ///< File of call
    135                 int lineno      ///< Line number of call
     136                psS32 lineno      ///< Line number of call
    136137               );
    137138
     
    148149 */
    149150void p_psMemSetDeallocator(
    150     void *ptr,                         ///< the memory block to operate on
     151    psPtr ptr,                         ///< the memory block to operate on
    151152    psFreeFcn freeFcn                  ///< the function to be executed at deallocation
    152153);
     
    162163 */
    163164psFreeFcn p_psMemGetDeallocator(
    164     void *ptr                          ///< the memory block
     165    psPtr ptr                          ///< the memory block
    165166);
    166167
     
    176177 */
    177178void p_psMemSetPersistent(
    178     void *ptr,                         ///< the memory block to operate on
    179     bool value                         ///< true if memory is persistent, otherwise false
     179    psPtr ptr,                         ///< the memory block to operate on
     180    psBool value                         ///< true if memory is persistent, otherwise false
    180181);
    181182
     
    187188 *  Memory marked as persistent is excluded from memory leak checks.
    188189 *
    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 */
     192psBool p_psMemGetPersistent(
     193    psPtr ptr                          ///< the memory block to check.
    193194);
    194195
     
    196197/** Memory re-allocation.  This operates much like realloc(), but is guaranteed to return a non-NULL value.
    197198 *
    198  *  @return void* pointer to resized buffer. This will not be NULL.
     199 *  @return psPtr pointer to resized buffer. This will not be NULL.
    199200 *  @see psAlloc, psFree
    200201 */
    201202#ifdef DOXYGEN
    202 void *psRealloc(
    203     void *ptr                          ///< Pointer to re-allocate
     203psPtr psRealloc(
     204    psPtr ptr                          ///< Pointer to re-allocate
    204205    size_t size,                       ///< Size required
    205206);
    206207#else
    207208
    208 void *p_psRealloc(
    209     void *ptr,                         ///< Pointer to re-allocate
     209psPtr p_psRealloc(
     210    psPtr ptr,                         ///< Pointer to re-allocate
    210211    size_t size,                       ///< Size required
    211212    const char *file,                  ///< File of call
    212     int lineno                         ///< Line number of call
     213    psS32 lineno                         ///< Line number of call
    213214);
    214215
     
    224225#ifdef DOXYGEN
    225226void psFree(
    226     void *ptr,                         ///< Pointer to free, if NULL, function returns immediately.
     227    psPtr ptr,                         ///< Pointer to free, if NULL, function returns immediately.
    227228);
    228229#else
    229230
    230231void p_psFree(
    231     void *ptr,                        ///< Pointer to free
     232    psPtr ptr,                        ///< Pointer to free
    232233    const char *file,                 ///< File of call
    233     int lineno                        ///< Line number of call
     234    psS32 lineno                        ///< Line number of call
    234235);
    235236
     
    248249 *  If memory leaks are found, the Memory Problem callback will be called as well.
    249250 *
    250  *  return int  number of memory blocks found as 'leaks', i.e., the number of currently allocated memory
     251 *  return psS32  number of memory blocks found as 'leaks', i.e., the number of currently allocated memory
    251252 *              blocks above id0 that have not been freed.
    252253 *  @see psAlloc, psFree, psgetMemId, psMemProblemCallbackSet
    253254 *  @ingroup memTracing
    254255 */
    255 int psMemCheckLeaks(
     256psS32 psMemCheckLeaks(
    256257    psMemoryId id0,                    ///< don't list blocks with id < id0
    257258    psMemBlock* ** arr,                ///< pointer to array of pointers to leaked blocks, or NULL
     
    264265 *  @ingroup memTracing
    265266 */
    266 int psMemCheckCorruption(
    267     bool abort_on_error                ///< Abort on detecting corruption?
     267psS32 psMemCheckCorruption(
     268    psBool abort_on_error                ///< Abort on detecting corruption?
    268269);
    269270
     
    273274 */
    274275psReferenceCount psMemGetRefCounter(
    275     void *vptr                         ///< Pointer to get refCounter for
     276    psPtr vptr                         ///< Pointer to get refCounter for
    276277);
    277278
     
    281282 */
    282283#ifdef DOXYGEN
    283 void *psMemIncrRefCounter(
    284     void *vptr                         ///< Pointer to increment refCounter, and return
    285 );
    286 #else
    287 
    288 void *p_psMemIncrRefCounter(
    289     void *vptr,                        ///< Pointer to increment refCounter, and return
     284psPtr psMemIncrRefCounter(
     285    psPtr vptr                         ///< Pointer to increment refCounter, and return
     286);
     287#else
     288
     289psPtr p_psMemIncrRefCounter(
     290    psPtr vptr,                        ///< Pointer to increment refCounter, and return
    290291    const char *file,                  ///< File of call
    291     int lineno                         ///< Line number of call
     292    psS32 lineno                         ///< Line number of call
    292293);
    293294
     
    299300 *  @ingroup memRefCount
    300301 *
    301  *  @return void*    the pointer deremented in refCount, or NULL if pointer is
     302 *  @return psPtr    the pointer deremented in refCount, or NULL if pointer is
    302303 *                   fully dereferenced.
    303304 */
    304305#ifdef DOXYGEN
    305 void* psMemDecrRefCounter(
    306     void* vptr                         ///< Pointer to decrement refCounter, and return
    307 );
    308 #else
    309 
    310 void *p_psMemDecrRefCounter(
    311     void *vptr,                        ///< Pointer to decrement refCounter, and return
     306psPtr psMemDecrRefCounter(
     307    psPtr vptr                         ///< Pointer to decrement refCounter, and return
     308);
     309#else
     310
     311psPtr p_psMemDecrRefCounter(
     312    psPtr vptr,                        ///< Pointer to decrement refCounter, and return
    312313    const char *file,                  ///< File of call
    313     int lineno                         ///< Line number of call
     314    psS32 lineno                         ///< Line number of call
    314315);
    315316
Note: See TracChangeset for help on using the changeset viewer.