Index: trunk/psLib/src/imageops/psImageStructManip.c
===================================================================
--- trunk/psLib/src/imageops/psImageStructManip.c	(revision 5057)
+++ trunk/psLib/src/imageops/psImageStructManip.c	(revision 5216)
@@ -8,6 +8,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-15 21:22:22 $
+ *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-10-01 02:22:11 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -96,5 +96,6 @@
         // if a child, need to orphan (disassociate from parent) first
         if (out->parent != NULL) {
-            psArrayRemove(out->parent->children,out); // remove from parent's knowledge
+            psArrayRemove(out->parent->children,psMemIncrRefCounter(out));
+            // remove from parent's knowledge without triggering a free
             out->parent = NULL; // break link to parent
         }
@@ -127,17 +128,6 @@
 
     // add output image as a child of the input image.
-    psS32 n = 0;
-    psArray* children = image->children;
-    if (children == NULL) {
-        children = psArrayAlloc(16); // start with a reasonable size for growth
-    } else if (children->nalloc == children->n) { // full?
-        n = children->n;
-        children = psArrayRealloc(children,n*2); // double the array size
-    } else {
-        n = children->n;
-    }
-    children->data[n] = out;
-    children->n = n+1;
-    image->children = children; // push back any change (esp. if children==NULL before)
+    image->children = psArrayAdd(image->children,16,out);
+    psMemDecrRefCounter(out); // don't count the reference held by parent as a true reference
 
     return (out);
