IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 30, 2005, 4:22:26 PM (21 years ago)
Author:
desonia
Message:

changed psArrayGet/psArraySet/psArrayRemove to do proper reference counting.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/imageops/psImageStructManip.c

    r5057 r5216  
    88 *  @author Robert DeSonia, MHPCC
    99 *
    10  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2005-09-15 21:22:22 $
     10 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2005-10-01 02:22:11 $
    1212 *
    1313 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    9696        // if a child, need to orphan (disassociate from parent) first
    9797        if (out->parent != NULL) {
    98             psArrayRemove(out->parent->children,out); // remove from parent's knowledge
     98            psArrayRemove(out->parent->children,psMemIncrRefCounter(out));
     99            // remove from parent's knowledge without triggering a free
    99100            out->parent = NULL; // break link to parent
    100101        }
     
    127128
    128129    // add output image as a child of the input image.
    129     psS32 n = 0;
    130     psArray* children = image->children;
    131     if (children == NULL) {
    132         children = psArrayAlloc(16); // start with a reasonable size for growth
    133     } else if (children->nalloc == children->n) { // full?
    134         n = children->n;
    135         children = psArrayRealloc(children,n*2); // double the array size
    136     } else {
    137         n = children->n;
    138     }
    139     children->data[n] = out;
    140     children->n = n+1;
    141     image->children = children; // push back any change (esp. if children==NULL before)
     130    image->children = psArrayAdd(image->children,16,out);
     131    psMemDecrRefCounter(out); // don't count the reference held by parent as a true reference
    142132
    143133    return (out);
Note: See TracChangeset for help on using the changeset viewer.