IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 9, 2004, 5:19:15 PM (22 years ago)
Author:
Paul Price
Message:

Doxygenation of Lupton stuff partially complete. Still need to hack some more to conform everything to coding standards.

File:
1 edited

Legend:

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

    r181 r196  
    22#define PS_MEMORY_H
    33#include <stdio.h>
    4 /*
    5  * Book-keeping data for storage allocator
     4/**
     5 * Book-keeping data for storage allocator.
    66 *
    77 * N.b. sizeof(psMemBlock) must be chosen such that if ptr is a pointer
     
    1010 */
    1111typedef struct {
    12     const void *magic0;                 // initialised to p_psMEMMAGIC
    13     const unsigned long id;             // a unique ID for this allocation
    14     const char *file;                   // set from __FILE__ in e.g. p_psAlloc
    15     const int lineno;                   // set from __LINE__ in e.g. p_psAlloc
    16     int refCounter;                     // how many times pointer is referenced
    17     const void *magic;                  // initialised to p_psMEMMAGIC
     12    const void *magic0;                 //!< initialised to p_psMEMMAGIC
     13    const unsigned long id;             //!< a unique ID for this allocation
     14    const char *file;                   //!< set from __FILE__ in e.g. p_psAlloc
     15    const int lineno;                   //!< set from __LINE__ in e.g. p_psAlloc
     16    int refCounter;                     //!< how many times pointer is referenced
     17    const void *magic;                  //!< initialised to p_psMEMMAGIC
    1818} psMemBlock;
    1919
     20/** */
    2021typedef int (*psMemCallback)(const psMemBlock *ptr);
    2122typedef void (*psMemProblemCallback)(const psMemBlock *ptr,
     
    2526/*****************************************************************************/
    2627
    27 void *psAlloc(size_t size);
    28 void *psRealloc(void *ptr, size_t size);
    29 void psFree(void *ptr);
     28/** Fake for p_psAlloc */
     29void *psAlloc(size_t size               //!< Size required
     30    );
     31/** Fake for p_psRealloc */
     32void *psRealloc(void *ptr,              //!< Pointer to re-allocate
     33                size_t size             //!< Size required
     34    );
     35/** Fake for p_psFree */
     36void psFree(void *ptr                   //!< Pointer to free
     37    );
    3038
    31 void *p_psAlloc(size_t size, const char *file, int lineno);
    32 void *p_psRealloc(void *ptr, size_t size, const char *file, int lineno);
    33 void p_psFree(void *ptr, const char *file, int lineno);
     39/** Memory allocation */
     40void *p_psAlloc(size_t size,            //!< Size required
     41                const char *file,       //!< File of call
     42                int lineno              //!< Line number of call
     43    );
    3444
     45/** Memory re-allocation */
     46void *p_psRealloc(void *ptr,            //!< Pointer to re-allocate
     47                  size_t size,          //!< Size required
     48                  const char *file,     //!< File of call
     49                  int lineno            //!< Line number of call
     50    );
     51
     52/** Free memory */
     53void p_psFree(void *ptr,                //!< Pointer to free
     54              const char *file,         //!< File of call
     55              int lineno                //!< Line number of call
     56    );
     57
     58/** psAlloc sends file and line number to p_psAlloc */
    3559#define psAlloc(size) p_psAlloc(size, __FILE__, __LINE__)
     60/** psRealloc sends file and line number to p_psRealloc */
    3661#define psRealloc(ptr, size) p_psRealloc(ptr, size, __FILE__, __LINE__)
     62/** psFree sends file and line number to p_psFree */
    3763#define psFree(size) p_psFree(size, __FILE__, __LINE__)
    3864
    3965/*****************************************************************************/
    40 /*
    41  * Checks of memory system
    42  */
    43 int psMemCheckLeaks(
    44     int id0,                            // don't list blocks with id < id0
    45     psMemBlock ***arr,                  // pointer to array of pointers to
    46                                         // leaked blocks, or NULL
    47     FILE *fd);                          // print list of leaks to fd (or NULL)
    48 int psMemCheckCorruption(int abort_on_error);
     66/** Check for memory leaks */
     67int psMemCheckLeaks(int id0,            //!< don't list blocks with id < id0
     68                    psMemBlock ***arr,  //!< pointer to array of pointers to leaked blocks, or NULL
     69                    FILE *fd            //!< print list of leaks to fd (or NULL)
     70    );
     71
     72/** Check for memory corruption */
     73int psMemCheckCorruption(int abort_on_error //!< Abort on detecting corruption?
     74    );
    4975
    5076/*****************************************************************************/
    51 /*
    52  * Manipulate reference counter
    53  */
    54 int psMemGetRefCounter(void *vptr);     // return refCounter
    55 void *psMemIncrRefCounter(void *vptr);  // increment refCounter and return vptr
    56 void *psMemDecrRefCounter(void *vptr);  // decrement refCounter and return vptr
     77
     78/** Return reference counter */
     79int psMemGetRefCounter(void *vptr       //!< Pointer to get refCounter for
     80    );
     81/** Increment reference counter and return the pointer */
     82void *psMemIncrRefCounter(void *vptr    //!< Pointer to increment refCounter, and return
     83    );
     84/** Decrement reference counter and return the pointer */
     85void *psMemDecrRefCounter(void *vptr    //!< Pointer to decrement refCounter, and return
     86    );
    5787
    5888/*****************************************************************************/
     
    6090 * Functions to set and control callbacks
    6191 */
    62 psMemProblemCallback psMemProblemSetCB(psMemProblemCallback func);
    63 psMemExhaustedCallback psMemExhaustedSetCB(psMemExhaustedCallback func);
    6492
    65 psMemCallback psMemAllocateSetCB(psMemCallback func);
    66 psMemCallback psMemFreeSetCB(psMemCallback func);
     93/** Set callback for problems */
     94psMemProblemCallback psMemProblemSetCB(psMemProblemCallback func //!< Function to run
     95    );
     96psMemExhaustedCallback psMemExhaustedSetCB(psMemExhaustedCallback func); //!< set call back for exhausted
     97                                                                         //!< memory
    6798
    68 int psMemGetId(void);                   // get next memory ID
    69 long psMemSetAllocateID(long id);       // set p_psMemAllocateID to id
    70 long psMemSetFreeID(long id);           // set p_psMemFreeID to id
     99psMemCallback psMemAllocateSetCB(psMemCallback func); //!< Set call back for when a particular memory block is
     100                                                      //!< allocated
     101psMemCallback psMemFreeSetCB(psMemCallback func); //!< set call back for when a particular memory block is
     102                                                  //!< freed
     103
     104int psMemGetId(void);                   //!< get next memory ID
     105long psMemSetAllocateID(long id);       //!< set p_psMemAllocateID to id
     106long psMemSetFreeID(long id);           //!< set p_psMemFreeID to id
    71107#endif
Note: See TracChangeset for help on using the changeset viewer.