IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11701


Ignore:
Timestamp:
Feb 7, 2007, 5:34:09 PM (19 years ago)
Author:
jhoblitt
Message:

change psArrayAlloc(), psArrayAllocEmpty(), & psArrayRealloc() into wrappers so file/lineo/func can be recorded in the memBlock
whitespace cleanup

Location:
trunk/psLib/src/types
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/types/psArray.c

    r10999 r11701  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.58 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2007-01-09 22:38:53 $
     11 *  @version $Revision: 1.59 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2007-02-08 03:34:09 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5454
    5555// Allocate an array, deliberately leave size unset.
    56 static psArray *arrayAlloc(long nalloc)
     56static psArray *arrayAlloc(const char *file,
     57                           unsigned int lineno,
     58                           const char *func,
     59                           long nalloc)
    5760{
    5861    if (nalloc < 0) {
     
    7780  FUNCTION IMPLEMENTATION - PUBLIC
    7881 *****************************************************************************/
    79 psArray* psArrayAlloc(long nalloc)
    80 {
    81     psArray *array = arrayAlloc(nalloc);
     82psArray* p_psArrayAlloc(const char *file,
     83                        unsigned int lineno,
     84                        const char *func,
     85                        long nalloc)
     86{
     87    psArray *array = arrayAlloc(file, lineno, func, nalloc);
    8288    if (!array) {
    8389        return NULL;
     
    8793}
    8894
    89 psArray* psArrayAllocEmpty(long nalloc)
    90 {
    91     psArray *array = arrayAlloc(nalloc);
     95psArray* p_psArrayAllocEmpty(const char *file,
     96                             unsigned int lineno,
     97                             const char *func,
     98                             long nalloc)
     99{
     100    psArray *array = arrayAlloc(file, lineno, func, nalloc);
    92101    if (!array) {
    93102        return NULL;
     
    97106}
    98107
    99 psArray* psArrayRealloc(psArray* in,
    100                         long nalloc)
     108psArray* p_psArrayRealloc(const char *file,
     109                          unsigned int lineno,
     110                          const char *func,
     111                          psArray* in,
     112                          long nalloc)
    101113{
    102114    if (nalloc < 0) {
     
    118130        // Realloc after decrementation to avoid accessing freed array elements
    119131        long n = in->n;
    120         in->data = psRealloc(in->data, nalloc * sizeof(psPtr));
     132        in->data = p_psRealloc(file, lineno, func, in->data, nalloc * sizeof(psPtr));
    121133        P_PSARRAY_SET_NALLOC(in,nalloc);
    122134        for (long m = n; m < nalloc; m++) { //if array is grown, set grown data to NULL
  • trunk/psLib/src/types/psArray.h

    r11668 r11701  
    88 *  @author Robert DeSonia, MHPCC
    99 *  @author Ross Harman, MHPCC
    10  *
    11  *  @version $Revision: 1.46 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2007-02-06 21:36:09 $
     10 *  @author Joshua Hoblitt, University of Hawaii
     11 *
     12 *  @version $Revision: 1.47 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2007-02-08 03:34:09 $
    1314 *
    1415 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4041#define P_PSARRAY_SET_NALLOC(vec,n) *(long*)&vec->nalloc = n
    4142
    42         /*****************************************************************************/
    43 
    44         /* FUNCTION PROTOTYPES                                                       */
    45 
    46         /*****************************************************************************/
    47 
    48         /** Checks the type of a particular pointer.
    49          *
    50          *  Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
    51          *
    52          *  @return bool:       True if the pointer matches a psArray structure, false otherwise.
    53          */
    54         bool psMemCheckArray(
    55             psPtr ptr                          ///< the pointer whose type to check
    56         )
    57         ;
     43/*****************************************************************************/
     44
     45/* FUNCTION PROTOTYPES                                                       */
     46
     47/*****************************************************************************/
     48
     49/** Checks the type of a particular pointer.
     50 *
     51 *  Uses the appropriate deallocation function in psMemBlock to check the ptr
     52 *  datatype.
     53 *
     54 *  @return bool:       True if the pointer matches a psArray structure, false
     55 *  otherwise.
     56 */
     57bool psMemCheckArray(
     58    psPtr ptr                          ///< the pointer whose type to check
     59)
     60;
    5861
    5962
     
    6669 *
    6770 */
     71#ifdef DOXYGEN
    6872psArray* psArrayAlloc(
    69     long nalloc                        ///< Total number of elements to make available.
    70 );
     73    long nalloc                         ///< Total number of elements to make available.
     74);
     75#else // ifdef DOXYGEN
     76psArray* p_psArrayAlloc(
     77    const char *file,                   ///< File of caller
     78    unsigned int lineno,                ///< Line number of caller
     79    const char *func,                   ///< Function name of caller
     80    long nalloc                         ///< Total number of elements to make available.
     81);
     82#define psArrayAlloc(nalloc) \
     83      p_psArrayAlloc(__FILE__, __LINE__, __func__, nalloc)
     84#endif // ifdef DOXYGEN
     85
    7186
    7287/** Allocate an array, set the length to zero.
     
    7893 *
    7994 */
     95#ifdef DOXYGEN
    8096psArray* psArrayAllocEmpty(
    81     long nalloc                        ///< Total number of elements to make available.
    82 );
     97    long nalloc                         ///< Total number of elements to make available.
     98);
     99#else // ifdef DOXYGEN
     100psArray* p_psArrayAllocEmpty(
     101    const char *file,                   ///< File of caller
     102    unsigned int lineno,                ///< Line number of caller
     103    const char *func,                   ///< Function name of caller
     104    long nalloc                         ///< Total number of elements to make available.
     105);
     106#define psArrayAllocEmpty(nalloc) \
     107      p_psArrayAllocEmpty(__FILE__, __LINE__, __func__, nalloc)
     108#endif // ifdef DOXYGEN
     109
    83110
    84111/** Reallocate an array.
     
    90117 *
    91118 */
     119#ifdef DOXYGEN
    92120psArray* psArrayRealloc(
    93121    psArray* array,                    ///< array to reallocate.
    94122    long nalloc                        ///< Total number of elements to make available.
    95123);
     124#else // ifdef DOXYGEN
     125psArray* p_psArrayRealloc(
     126    const char *file,                   ///< File of caller
     127    unsigned int lineno,                ///< Line number of caller
     128    const char *func,                   ///< Function name of caller
     129    psArray* array,                    ///< array to reallocate.
     130    long nalloc                        ///< Total number of elements to make available.
     131);
     132#define psArrayRealloc(array, nalloc) \
     133      p_psArrayRealloc(__FILE__, __LINE__, __func__, array, nalloc)
     134#endif // ifdef DOXYGEN
     135
    96136
    97137/** Add an element to the end the array, expanding the array storage if
     
    102142psArray* psArrayAdd(
    103143    psArray* array,                    ///< array to operate on
    104     long delta,
    105     ///< the amount to expand array, if necessary.  If less than one, 10 will be used.
     144    long delta,                        ///< the amount to expand array, if necessary.  If less than one, 10 will be used.
    106145    psPtr data                         ///< the data pointer to add to psArray
    107146);
     147
    108148
    109149/** Remove an element from the array by it's pointer
     
    120160);
    121161
     162
    122163/** Remove an element from the array
    123164 *
     
    133174);
    134175
     176
    135177/** Deallocate/Dereference elements of an array.
    136178 *
     
    144186);
    145187
     188
    146189/** Sort the array according to an external compare function.
    147190 *
     
    162205    psComparePtrFunc func                 ///< the compare function
    163206);
     207
    164208
    165209/** Set an element in the array.  If the current element is non-NULL, the old
     
    174218);
    175219
     220
    176221/** Get an element from the array.
    177222 *
     
    182227    long position                      ///< the element position to get
    183228);
     229
    184230
    185231/** Get the number of elements in use from a specified psArray. (array.n)
Note: See TracChangeset for help on using the changeset viewer.