Index: /trunk/psLib/src/collections/psArray.c
===================================================================
--- /trunk/psLib/src/collections/psArray.c	(revision 2792)
+++ /trunk/psLib/src/collections/psArray.c	(revision 2793)
@@ -9,6 +9,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-11-19 00:33:39 $
+ *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-12-23 01:14:52 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -36,4 +36,15 @@
 /*****************************************************************************/
 static void arrayFree(psArray* restrict psArr);
+
+static void arrayFree(psArray* restrict psArr)
+{
+    if (psArr == NULL) {
+        return;
+    }
+
+    psArrayElementFree(psArr);
+
+    psFree(psArr->data);
+}
 
 /*****************************************************************************/
@@ -79,13 +90,25 @@
 }
 
-static void arrayFree(psArray* restrict psArr)
+psArray* psArrayAdd(psArray* psArr,
+                    int delta,
+                    psPtr data)
 {
     if (psArr == NULL) {
-        return;
+        return psArr;
     }
 
-    psArrayElementFree(psArr);
+    int n = psArr->n;
 
-    psFree(psArr->data);
+    if (n >= psArr->nalloc) {
+        // array needs to be expanded to make room for more elements
+        int d = (delta > 0) ? delta : 10; // as spec'ed in SDRS.
+        psArr = psArrayRealloc(psArr, n+d);
+    }
+
+    // add the element to the end of the array.
+    psArr->data[n] = data;
+    psArr->n = n+1;
+
+    return psArr;
 }
 
@@ -95,7 +118,4 @@
     psBool success = false;
 
-    if (psArr == NULL) {
-        return success;
-    }
 
     psS32 n = psArr->n;
Index: /trunk/psLib/src/collections/psArray.h
===================================================================
--- /trunk/psLib/src/collections/psArray.h	(revision 2792)
+++ /trunk/psLib/src/collections/psArray.h	(revision 2793)
@@ -12,6 +12,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-12-23 01:14:52 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -68,5 +68,17 @@
 psArray* psArrayRealloc(
     psArray* restrict psArr,           ///< array to reallocate.
-    psU32 nalloc                ///< Total number of elements to make available.
+    psU32 nalloc                       ///< Total number of elements to make available.
+);
+
+/** Add an element to the end the array, expanding the array storage if
+ *  necessary.
+ *
+ *  @return psArray*        The array with the element added
+ */
+psArray* psArrayAdd(
+    psArray* psArr,                    ///< array to operate on
+    int delta,
+    ///< the amount to expand array, if necessary.  If less than one, 10 will be used.
+    psPtr data                         ///< the data pointer to add to psArray
 );
 
Index: /trunk/psLib/src/types/psArray.c
===================================================================
--- /trunk/psLib/src/types/psArray.c	(revision 2792)
+++ /trunk/psLib/src/types/psArray.c	(revision 2793)
@@ -9,6 +9,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-11-19 00:33:39 $
+ *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-12-23 01:14:52 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -36,4 +36,15 @@
 /*****************************************************************************/
 static void arrayFree(psArray* restrict psArr);
+
+static void arrayFree(psArray* restrict psArr)
+{
+    if (psArr == NULL) {
+        return;
+    }
+
+    psArrayElementFree(psArr);
+
+    psFree(psArr->data);
+}
 
 /*****************************************************************************/
@@ -79,13 +90,25 @@
 }
 
-static void arrayFree(psArray* restrict psArr)
+psArray* psArrayAdd(psArray* psArr,
+                    int delta,
+                    psPtr data)
 {
     if (psArr == NULL) {
-        return;
+        return psArr;
     }
 
-    psArrayElementFree(psArr);
+    int n = psArr->n;
 
-    psFree(psArr->data);
+    if (n >= psArr->nalloc) {
+        // array needs to be expanded to make room for more elements
+        int d = (delta > 0) ? delta : 10; // as spec'ed in SDRS.
+        psArr = psArrayRealloc(psArr, n+d);
+    }
+
+    // add the element to the end of the array.
+    psArr->data[n] = data;
+    psArr->n = n+1;
+
+    return psArr;
 }
 
@@ -95,7 +118,4 @@
     psBool success = false;
 
-    if (psArr == NULL) {
-        return success;
-    }
 
     psS32 n = psArr->n;
Index: /trunk/psLib/src/types/psArray.h
===================================================================
--- /trunk/psLib/src/types/psArray.h	(revision 2792)
+++ /trunk/psLib/src/types/psArray.h	(revision 2793)
@@ -12,6 +12,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-10-27 00:57:31 $
+ *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-12-23 01:14:52 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -68,5 +68,17 @@
 psArray* psArrayRealloc(
     psArray* restrict psArr,           ///< array to reallocate.
-    psU32 nalloc                ///< Total number of elements to make available.
+    psU32 nalloc                       ///< Total number of elements to make available.
+);
+
+/** Add an element to the end the array, expanding the array storage if
+ *  necessary.
+ *
+ *  @return psArray*        The array with the element added
+ */
+psArray* psArrayAdd(
+    psArray* psArr,                    ///< array to operate on
+    int delta,
+    ///< the amount to expand array, if necessary.  If less than one, 10 will be used.
+    psPtr data                         ///< the data pointer to add to psArray
 );
 
