Index: /trunk/psLib/src/collections/psVector.c
===================================================================
--- /trunk/psLib/src/collections/psVector.c	(revision 810)
+++ /trunk/psLib/src/collections/psVector.c	(revision 811)
@@ -19,6 +19,6 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-05-14 21:05:52 $
+ *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-29 01:08:46 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -91,8 +91,8 @@
 }
 
-psVector *psVectorRealloc(psVector *restrict psVec, unsigned int nalloc)
+psVector *psVectorRealloc(psVector *restrict in, unsigned int nalloc)
 {
     int elementSize = 0;
-    psElemType elemType = psVec->type.type;
+    psElemType elemType;
 
     // Invalid nalloc
@@ -102,24 +102,64 @@
     }
 
-    elementSize = PSELEMTYPE_SIZEOF(elemType);
-
-    if(psVec == NULL) {                                     // For creating new psVector
-        psVec = psVectorAlloc(psVec->type.type, nalloc);
-    } else if(psVec->nalloc != nalloc) {                    // No need to realloc to same size
-        if(nalloc < psVec->n) {
+    if(in == NULL) {                                     // For creating new psVector
+        return NULL;
+    } else if(in->nalloc != nalloc) {                    // No need to realloc to same size
+        elemType = in->type.type;
+        elementSize = PSELEMTYPE_SIZEOF(elemType);
+        if(nalloc < in->n) {
             if (elemType == PS_TYPE_PTR) {
-                for (int i = nalloc; i < psVec->n; i++) {   // For reduction in vector size
-                    psMemDecrRefCounter(psVec->vec.vp[i]);
+                for (int i = nalloc; i < in->n; i++) {   // For reduction in vector size
+                    psMemDecrRefCounter(in->vec.vp[i]);
                 }
             }
-            psVec->n = nalloc;
+            in->n = nalloc;
         }
 
         // Realloc after decrementation to avoid accessing freed array elements
-        psVec->vec.v = psRealloc(psVec->vec.v,nalloc*elementSize);
-        psVec->nalloc = nalloc;
+        in->vec.v = psRealloc(in->vec.v,nalloc*elementSize);
+        in->nalloc = nalloc;
     }
 
-    return psVec;
+    return in;
+}
+
+psVector *psVectorRecycle(psVector *restrict in, psElemType type, unsigned int nalloc)
+{
+    psElemType elemType;
+
+    if (in == NULL) {
+        return psVectorAlloc(type,nalloc);
+    }
+
+    elemType = in->type.type;
+
+    if (in->nalloc == nalloc && elemType == type) {
+        // it is proper size/type already
+        return in;
+    }
+
+    // Invalid nalloc
+    if(nalloc < 1) {
+        psError(__func__, "Invalid value for nalloc (%d)\n", nalloc);
+        psVectorFree(in);
+        return NULL;
+    }
+
+
+    // if vector of pointers, dereference old values.
+    if (elemType == PS_TYPE_PTR) {
+        for (int i = 0; i < in->n; i++) {   // For reduction in vector size
+            psMemDecrRefCounter(in->vec.vp[i]);
+            in->vec.vp[i] = NULL;
+        }
+    }
+
+    in->vec.v = psRealloc(in->vec.v,nalloc*PSELEMTYPE_SIZEOF(elemType));
+
+    in->n = 0;
+    in->type.type = elemType;
+    in->nalloc = nalloc;
+
+    return in;
 }
 
Index: /trunk/psLib/src/collections/psVector.h
===================================================================
--- /trunk/psLib/src/collections/psVector.h	(revision 810)
+++ /trunk/psLib/src/collections/psVector.h	(revision 811)
@@ -19,6 +19,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-05-13 23:36:27 $
+ *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-29 01:08:46 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -88,4 +88,20 @@
 );
 
+/** Recycle a vector.
+ *
+ * Uses psLib memory allocation functions to reallocate a vector collection of data. The vector is reallocated
+ * according to the psElemType type parameter.
+ *
+ * @return psVector*: Pointer to psVector.
+ *
+ */
+psVector *psVectorRecycle(
+    psVector *restrict psVec,
+    ///< Vector to recycle.  If NULL, a new vector is created.  No effort taken to preserve the values.
+
+    unsigned int nalloc,                ///< Total number of elements to make available.
+    psElemType type                     ///< the datatype of the returned vector
+);
+
 /** Deallocate a vector.
  *
Index: /trunk/psLib/src/mathtypes/psVector.c
===================================================================
--- /trunk/psLib/src/mathtypes/psVector.c	(revision 810)
+++ /trunk/psLib/src/mathtypes/psVector.c	(revision 811)
@@ -19,6 +19,6 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-05-14 21:05:52 $
+ *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-29 01:08:46 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -91,8 +91,8 @@
 }
 
-psVector *psVectorRealloc(psVector *restrict psVec, unsigned int nalloc)
+psVector *psVectorRealloc(psVector *restrict in, unsigned int nalloc)
 {
     int elementSize = 0;
-    psElemType elemType = psVec->type.type;
+    psElemType elemType;
 
     // Invalid nalloc
@@ -102,24 +102,64 @@
     }
 
-    elementSize = PSELEMTYPE_SIZEOF(elemType);
-
-    if(psVec == NULL) {                                     // For creating new psVector
-        psVec = psVectorAlloc(psVec->type.type, nalloc);
-    } else if(psVec->nalloc != nalloc) {                    // No need to realloc to same size
-        if(nalloc < psVec->n) {
+    if(in == NULL) {                                     // For creating new psVector
+        return NULL;
+    } else if(in->nalloc != nalloc) {                    // No need to realloc to same size
+        elemType = in->type.type;
+        elementSize = PSELEMTYPE_SIZEOF(elemType);
+        if(nalloc < in->n) {
             if (elemType == PS_TYPE_PTR) {
-                for (int i = nalloc; i < psVec->n; i++) {   // For reduction in vector size
-                    psMemDecrRefCounter(psVec->vec.vp[i]);
+                for (int i = nalloc; i < in->n; i++) {   // For reduction in vector size
+                    psMemDecrRefCounter(in->vec.vp[i]);
                 }
             }
-            psVec->n = nalloc;
+            in->n = nalloc;
         }
 
         // Realloc after decrementation to avoid accessing freed array elements
-        psVec->vec.v = psRealloc(psVec->vec.v,nalloc*elementSize);
-        psVec->nalloc = nalloc;
+        in->vec.v = psRealloc(in->vec.v,nalloc*elementSize);
+        in->nalloc = nalloc;
     }
 
-    return psVec;
+    return in;
+}
+
+psVector *psVectorRecycle(psVector *restrict in, psElemType type, unsigned int nalloc)
+{
+    psElemType elemType;
+
+    if (in == NULL) {
+        return psVectorAlloc(type,nalloc);
+    }
+
+    elemType = in->type.type;
+
+    if (in->nalloc == nalloc && elemType == type) {
+        // it is proper size/type already
+        return in;
+    }
+
+    // Invalid nalloc
+    if(nalloc < 1) {
+        psError(__func__, "Invalid value for nalloc (%d)\n", nalloc);
+        psVectorFree(in);
+        return NULL;
+    }
+
+
+    // if vector of pointers, dereference old values.
+    if (elemType == PS_TYPE_PTR) {
+        for (int i = 0; i < in->n; i++) {   // For reduction in vector size
+            psMemDecrRefCounter(in->vec.vp[i]);
+            in->vec.vp[i] = NULL;
+        }
+    }
+
+    in->vec.v = psRealloc(in->vec.v,nalloc*PSELEMTYPE_SIZEOF(elemType));
+
+    in->n = 0;
+    in->type.type = elemType;
+    in->nalloc = nalloc;
+
+    return in;
 }
 
Index: /trunk/psLib/src/mathtypes/psVector.h
===================================================================
--- /trunk/psLib/src/mathtypes/psVector.h	(revision 810)
+++ /trunk/psLib/src/mathtypes/psVector.h	(revision 811)
@@ -19,6 +19,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-05-13 23:36:27 $
+ *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-29 01:08:46 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -88,4 +88,20 @@
 );
 
+/** Recycle a vector.
+ *
+ * Uses psLib memory allocation functions to reallocate a vector collection of data. The vector is reallocated
+ * according to the psElemType type parameter.
+ *
+ * @return psVector*: Pointer to psVector.
+ *
+ */
+psVector *psVectorRecycle(
+    psVector *restrict psVec,
+    ///< Vector to recycle.  If NULL, a new vector is created.  No effort taken to preserve the values.
+
+    unsigned int nalloc,                ///< Total number of elements to make available.
+    psElemType type                     ///< the datatype of the returned vector
+);
+
 /** Deallocate a vector.
  *
