Index: trunk/psLib/src/collections/psVector.c
===================================================================
--- trunk/psLib/src/collections/psVector.c	(revision 3786)
+++ trunk/psLib/src/collections/psVector.c	(revision 4212)
@@ -9,6 +9,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.41 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-04-29 02:25:09 $
+*  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-06-10 21:46:46 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -54,4 +54,10 @@
 
     elementSize = PSELEMTYPE_SIZEOF(elemType);
+    if (elementSize < 1) {
+        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
+                PS_ERRORTEXT_psVector_UNSUPPORTED_TYPE, elemType);
+        return NULL;
+    }
+
 
     // Create vector struct
@@ -121,4 +127,41 @@
     in->n = n;
     return in;
+}
+
+psVector *psVectorExtend(psVector *vector, int delta, int nExtend)
+{
+    // can't handle a NULL vector (don't know the data type to allocate)
+    if (vector == NULL) {
+        psError(PS_ERR_BAD_PARAMETER_NULL, true,
+                PS_ERRORTEXT_psVector_NULL);
+        return NULL;
+    }
+
+    // requirement on delta; if < 1, set to 10.
+    if (delta < 1) {
+        delta = 10;
+    }
+
+    // adjust the allocated size, if needed. (if nExtend < 1, this is will never happen)
+    if (nExtend > 0) {
+        unsigned int minAlloc = vector->n + nExtend + nExtend;
+        if (vector->nalloc < minAlloc) {
+            unsigned int nAlloc = delta + vector->nalloc;
+            // make sure the delta is large enough hold twice the extended length.
+            if (nAlloc < minAlloc) {
+                nAlloc = minAlloc;
+            }
+            vector = psVectorRealloc(vector, nAlloc);
+        }
+    } else if (nExtend < -vector->n) {
+        // For the case of a negative nExtend, need to check that we are not decreasing
+        // vector beyond its own length (i.e., creating a negative length).
+        nExtend = -vector->n;
+    }
+
+    // increment the length by the value specified
+    vector->n += nExtend;
+
+    return vector;
 }
 
