IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15454


Ignore:
Timestamp:
Nov 5, 2007, 1:42:46 PM (19 years ago)
Author:
Paul Price
Message:

Propagating allocation information, so leaks can be tracked down easier.

Location:
trunk/psLib/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/mathtypes/psImage.c

    r14921 r15454  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.130 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2007-09-20 23:48:30 $
     11 *  @version $Revision: 1.131 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2007-11-05 23:42:46 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4444    // if I am a child, remove me from my parent's array of children
    4545    if (parent != NULL) {
    46         // sanity check : a child cannot also be a parent
    47         if ((image->children != NULL) && (image->children->n > 0)) {
    48             psAbort ("psImage cannot be both child and parent!");
    49         }
    50 
    51         // break the back-pointer first so we don't loop
    52         image->parent = NULL; 
    53 
    54         // drop my entry on my parent's array of children
    55         psArrayRemoveDataNoFree (parent->children, image);
    56        
    57         // drop my reference to my parent
    58         psFree (parent);
    59     }
    60    
     46        // sanity check : a child cannot also be a parent
     47        if ((image->children != NULL) && (image->children->n > 0)) {
     48            psAbort ("psImage cannot be both child and parent!");
     49        }
     50
     51        // break the back-pointer first so we don't loop
     52        image->parent = NULL;
     53
     54        // drop my entry on my parent's array of children
     55        psArrayRemoveDataNoFree (parent->children, image);
     56
     57        // drop my reference to my parent
     58        psFree (parent);
     59    }
     60
    6161    // sanity check: this function should never be reached if an image still has live children;
    6262    // they should each be holding a pointer to the image, forcing the number of references to
    6363    // be > 1.
    6464    if (image->children && (image->children->n > 0)) {
    65         psAbort ("psImage memory management programming error : imageFree called on image with live children");
     65        psAbort ("psImage memory management programming error : imageFree called on image with live children");
    6666    }
    6767
     
    100100    psMemSetDeallocator(image, (psFreeFunc) imageFree);
    101101
    102     image->data.V = psAlloc(sizeof(psPtr ) * numRows);
    103 
    104     image->p_rawDataBuffer = psAlloc(numBytes);
     102    image->data.V = p_psAlloc(file, lineno, func, sizeof(psPtr ) * numRows);
     103
     104    image->p_rawDataBuffer = p_psAlloc(file, lineno, func, numBytes);
    105105
    106106    // set the row pointers.
  • trunk/psLib/src/types/psArray.c

    r15115 r15454  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.64 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2007-09-29 22:18:09 $
     11 *  @version $Revision: 1.65 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2007-11-05 23:42:46 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    139139}
    140140
    141 psArray* psArrayAdd(psArray* array,
    142                     long delta,
    143                     psPtr data)
     141psArray* p_psArrayAdd(const char *file, unsigned int lineno, const char *func,
     142                      psArray* array, long delta, psPtr data)
    144143{
    145144    if (array == NULL) {
    146145        long d = (delta > 0) ? delta : DEFAULT_ARRAY_ADD;
    147         array = psArrayAlloc(d);
     146        array = p_psArrayAlloc(file, lineno, func, d);
    148147        array->n = 0;
    149148    }
     
    154153        // array needs to be expanded to make room for more elements
    155154        long d = (delta > 0) ? delta : DEFAULT_ARRAY_ADD;
    156         array = psArrayRealloc(array, n+d);
     155        array = p_psArrayRealloc(file, lineno, func, array, n+d);
    157156    }
    158157
     
    187186}
    188187
    189 // drop an item from the array and do not free it: this 
     188// drop an item from the array and do not free it: this
    190189// can be useful in the free function of a data type
    191190// with a reference on another structure
    192191bool psArrayRemoveDataNoFree(psArray* array,
    193                              const psPtr data)
     192                             const psPtr data)
    194193{
    195194    PS_ASSERT_ARRAY_NON_NULL(array, false);
     
    268267    while (1) {
    269268        if (I > 0) {
    270             // I--;
     269            // I--;
    271270            temp = index[--I];
    272271        } else {
    273272            temp = index[J];
    274273            index[J] = index[0];
    275             // J--;
     274            // J--;
    276275            if (--J == 0) {
    277276                index[0] = temp;
     
    282281        long j = (I << 1) + 1;
    283282        while (j <= J) {
    284             if (j < J) {
    285                 result = func (in->data[index[j]], in->data[index[j+1]]);
    286                 if (result < 0) {
    287                     j++;
    288                 }
    289             }
    290             result = func (in->data[temp], in->data[index[j]]);
     283            if (j < J) {
     284                result = func (in->data[index[j]], in->data[index[j+1]]);
     285                if (result < 0) {
     286                    j++;
     287                }
     288            }
     289            result = func (in->data[temp], in->data[index[j]]);
    291290            if (result < 0) {
    292291                index[i]=index[j];
  • trunk/psLib/src/types/psArray.h

    r15076 r15454  
    1010 *  @author Joshua Hoblitt, University of Hawaii
    1111 *
    12  *  @version $Revision: 1.51 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2007-09-28 21:03:24 $
     12 *  @version $Revision: 1.52 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2007-11-05 23:42:46 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    139139 *  necessary.
    140140 *
     141 *  If delta < 1, then 10 is used.
     142 *
    141143 *  @return psArray*        The array with the element added
    142144 */
    143145psArray* psArrayAdd(
    144146    psArray* array,                    ///< array to operate on
    145     long delta,                        ///< the amount to expand array, if necessary.  If less than one, 10 will be used.
     147    long delta,                        ///< the amount to expand array, if necessary.
    146148    psPtr data                         ///< the data pointer to add to psArray
    147149);
     150#ifdef DOXYGEN
     151psArray* psArrayAdd(
     152    psArray* array,                    ///< array to operate on
     153    long delta,                        ///< the amount to expand array, if necessary.
     154    psPtr data                         ///< the data pointer to add to psArray
     155);
     156#else // ifdef DOXYGEN
     157psArray* p_psArrayAdd(
     158    const char *file,                   ///< File of caller
     159    unsigned int lineno,                ///< Line number of caller
     160    const char *func,                   ///< Function name of caller
     161    psArray* array,                     ///< array to operate on
     162    long delta,                         ///< the amount to expand array, if necessary.
     163    psPtr data                          ///< the data pointer to add to psArray
     164) PS_ATTR_MALLOC;
     165#define psArrayAdd(array, delta, data) \
     166      p_psArrayAdd(__FILE__, __LINE__, __func__, array, delta, data)
     167#endif // ifdef DOXYGEN
    148168
    149169
Note: See TracChangeset for help on using the changeset viewer.