Index: /trunk/psLib/src/collections/psSort.c
===================================================================
--- /trunk/psLib/src/collections/psSort.c	(revision 669)
+++ /trunk/psLib/src/collections/psSort.c	(revision 670)
@@ -14,6 +14,6 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-05-13 20:25:00 $
+ *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-13 22:47:52 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -189,5 +189,5 @@
     outN = outVector->n;
     inVec = inVector->vec.f;
-    outVec = outVector->vec.i;
+    outVec = outVector->vec.i32;
 
     if(inN != outN) {
Index: /trunk/psLib/src/collections/psVector.c
===================================================================
--- /trunk/psLib/src/collections/psVector.c	(revision 669)
+++ /trunk/psLib/src/collections/psVector.c	(revision 670)
@@ -3,5 +3,5 @@
  *  @brief Contains support for basic vector types
  *
- *  This file defines types and functions for one dimensional vectors which include: 
+ *  This file defines types and functions for one dimensional vectors which include:
  *      char
  *      short
@@ -19,6 +19,6 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-05-13 20:25:00 $
+ *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-13 22:47:52 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -31,4 +31,5 @@
 #include "psError.h"
 #include "psVector.h"
+#include "psLogMsg.h"
 
 /******************************************************************************/
@@ -60,7 +61,26 @@
 /*****************************************************************************/
 
-static void* p_psVectorAlloc(psVector *restrict psVec, psElemType elemType, int nalloc, int elemSize)
+/*****************************************************************************/
+/* FUNCTION IMPLEMENTATION - PUBLIC                                          */
+/*****************************************************************************/
+psVector* psVectorAlloc(psElemType elemType, unsigned int nalloc)
 {
-    void *vec = NULL;
+    psVector *psVec = NULL;
+    int elementSize = 0;
+
+    // Invalid nalloc
+    if(nalloc < 1) {
+        psError(__func__, "Invalid value for nalloc. nalloc: %d\n", nalloc);
+        return NULL;
+    }
+
+    if (elemType == PS_TYPE_PTR) {
+        elementSize = sizeof(void*);
+    } else {
+        elementSize = PSELEMTYPE_SIZEOF(elemType);
+    }
+
+    // Create vector struct
+    psVec = (psVector *)psAlloc(sizeof(psVector));
 
     psVec->type.dimen = PS_DIMEN_VECTOR;
@@ -69,139 +89,40 @@
     psVec->n = 0;
 
-    if(nalloc != 0) {
-        vec = psAlloc(nalloc*sizeof(elemSize));
-    }
+    // Create vector data array
+    psVec->vec.v = psAlloc(nalloc*elementSize);
 
-    return vec;
+    return psVec;
 }
 
-static void* p_psVectorRealloc(psVector *restrict psVec, void *vec, int nalloc, int elemSize)
+psVector *psVectorRealloc(psVector *restrict psVec, unsigned int nalloc)
 {
-    // For decrease in psVector size
-    if(nalloc < psVec->n) {
-        psVec->n = nalloc;
-    }
-
-    psVec->nalloc = nalloc;
-
-    return psRealloc(vec, nalloc*elemSize);
-}
-
-/*****************************************************************************/
-/* FUNCTION IMPLEMENTATION - PUBLIC                                          */
-/*****************************************************************************/
-psVector* psVectorAlloc(psElemType elemType, int nalloc)
-{
-    psVector *psVec = NULL;
-    psElemType vecType = 0;
-
-    vecType = elemType;
+    int elementSize = 0;
+    psElemType elemType = psVec->type.type;
 
     // Invalid nalloc
-    if(nalloc <= 0) {
+    if(nalloc < 1) {
         psError(__func__, " : Line %d - Invalid value for nalloc. nalloc: %d\n", __LINE__, nalloc);
         return NULL;
     }
 
-    // Create vector struct
-    psVec = (psVector *)psAlloc(sizeof(psVector));
-
-    // Create vector data array
-    switch(vecType) {
-    case PS_TYPE_CHAR:
-        psVec->vec.c = (char *)p_psVectorAlloc(psVec, PS_TYPE_CHAR, nalloc, sizeof(char));
-        break;
-    case PS_TYPE_SHORT:
-        psVec->vec.s = (short *)p_psVectorAlloc(psVec, PS_TYPE_SHORT, nalloc, sizeof(short));
-        break;
-    case PS_TYPE_INT:
-        psVec->vec.i = (int *)p_psVectorAlloc(psVec, PS_TYPE_INT, nalloc, sizeof(int));
-        break;
-    case PS_TYPE_LONG:
-        psVec->vec.l = (long *)p_psVectorAlloc(psVec, PS_TYPE_LONG, nalloc, sizeof(long));
-        break;
-    case PS_TYPE_UCHAR:
-        psVec->vec.uc = (unsigned char *)p_psVectorAlloc(psVec, PS_TYPE_UCHAR, nalloc, sizeof(unsigned char));
-        break;
-    case PS_TYPE_USHORT:
-        psVec->vec.us = (unsigned short *)p_psVectorAlloc(psVec, PS_TYPE_USHORT, nalloc, sizeof(unsigned short));
-        break;
-    case PS_TYPE_UINT:
-        psVec->vec.ui = (unsigned int *)p_psVectorAlloc(psVec, PS_TYPE_UINT, nalloc, sizeof(unsigned int));
-        break;
-    case PS_TYPE_ULONG:
-        psVec->vec.ul = (unsigned long *)p_psVectorAlloc(psVec, PS_TYPE_ULONG, nalloc, sizeof(unsigned long));
-        break;
-    case PS_TYPE_FLOAT:
-        psVec->vec.f = (float *)p_psVectorAlloc(psVec, PS_TYPE_FLOAT, nalloc, sizeof(float));
-        break;
-    case PS_TYPE_DOUBLE:
-        psVec->vec.d = (double *)p_psVectorAlloc(psVec, PS_TYPE_DOUBLE, nalloc, sizeof(double));
-        break;
-    case PS_TYPE_COMPLEX:
-        psVec->vec.cf = (complex float *)p_psVectorAlloc(psVec, PS_TYPE_COMPLEX, nalloc, sizeof(complex float));
-        break;
-    case PS_TYPE_OTHER:
-        break;
-    default:
-        psError(__func__, " : Line %d - Invalid vector type. Type: %d\n", __LINE__, vecType);
+    if (elemType == PS_TYPE_PTR) {
+        elementSize = sizeof(void*);
+    } else {
+        elementSize = PSELEMTYPE_SIZEOF(elemType);
     }
 
-    return psVec;
-}
-
-psVector *psVectorRealloc(psVector *restrict psVec, int nalloc)
-{
-    psElemType vecType = 0;
-
-    vecType = psVec->type.type;
-
-    // Invalid nalloc
-    if(nalloc < 0) {
-        psError(__func__, " : Line %d - Invalid value for nalloc. nalloc: %d\n", __LINE__, nalloc);
-        return NULL;
-    }
 
     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
-        switch (vecType) {
-        case PS_TYPE_CHAR:
-            psVec->vec.c = p_psVectorRealloc(psVec, psVec->vec.c, nalloc, sizeof(char));
-            break;
-        case PS_TYPE_SHORT:
-            psVec->vec.s = p_psVectorRealloc(psVec, psVec->vec.s, nalloc, sizeof(short));
-            break;
-        case PS_TYPE_INT:
-            psVec->vec.i = p_psVectorRealloc(psVec, psVec->vec.i, nalloc, sizeof(int));
-            break;
-        case PS_TYPE_LONG:
-            psVec->vec.l = p_psVectorRealloc(psVec, psVec->vec.l, nalloc, sizeof(long));
-            break;
-        case PS_TYPE_UCHAR:
-            psVec->vec.uc = p_psVectorRealloc(psVec, psVec->vec.uc, nalloc, sizeof(unsigned char));
-            break;
-        case PS_TYPE_USHORT:
-            psVec->vec.us = p_psVectorRealloc(psVec, psVec->vec.us, nalloc, sizeof(unsigned short));
-            break;
-        case PS_TYPE_UINT:
-            psVec->vec.ui = p_psVectorRealloc(psVec, psVec->vec.ui, nalloc, sizeof(unsigned int));
-            break;
-        case PS_TYPE_ULONG:
-            psVec->vec.ul = p_psVectorRealloc(psVec, psVec->vec.ul, nalloc, sizeof(unsigned long));
-            break;
-        case PS_TYPE_FLOAT:
-            psVec->vec.f = p_psVectorRealloc(psVec, psVec->vec.f, nalloc, sizeof(float));
-            break;
-        case PS_TYPE_DOUBLE:
-            psVec->vec.d = p_psVectorRealloc(psVec, psVec->vec.d, nalloc, sizeof(double));
-            break;
-        case PS_TYPE_COMPLEX:
-            psVec->vec.cf = p_psVectorRealloc(psVec, psVec->vec.cf, nalloc, sizeof(complex float));
-            break;
-        case PS_TYPE_OTHER:
-            break;
-        default:
-            psError(__func__, " : Line %d - Invalid vector type. Type: %d\n", __LINE__, vecType);
+        psVec->vec.v = psRealloc(psVec->vec.v,nalloc*elementSize);
+        psVec->nalloc = nalloc;
+        if(nalloc < psVec->n) {
+            if (elemType == PS_TYPE_PTR) {
+                for (int i = nalloc; i < psVec->n; i++) {               // For reduction in vector size
+                    psMemDecrRefCounter(psVec->vec.vp[i]);
+                }
+            }
+            psVec->n = nalloc;
         }
     }
@@ -212,84 +133,20 @@
 void psVectorFree(psVector *restrict psVec)
 {
-    psElemType vecType = 0;
-
-    vecType = psVec->type.type;
-
     if (psVec == NULL) {
         return;
     }
 
-    switch (vecType) {
-    case PS_TYPE_CHAR:
-        psFree(psVec->vec.c);
-        break;
-    case PS_TYPE_SHORT:
-        psFree(psVec->vec.s);
-        break;
-    case PS_TYPE_INT:
-        psFree(psVec->vec.i);
-        break;
-    case PS_TYPE_LONG:
-        psFree(psVec->vec.l);
-        break;
-    case PS_TYPE_UCHAR:
-        psFree(psVec->vec.uc);
-        break;
-    case PS_TYPE_USHORT:
-        psFree(psVec->vec.us);
-        break;
-    case PS_TYPE_UINT:
-        psFree(psVec->vec.ui);
-        break;
-    case PS_TYPE_ULONG:
-        psFree(psVec->vec.ul);
-        break;
-    case PS_TYPE_FLOAT:
-        psFree(psVec->vec.f);
-        break;
-    case PS_TYPE_DOUBLE:
-        psFree(psVec->vec.d);
-        break;
-    case PS_TYPE_COMPLEX:
-        psFree(psVec->vec.cf);
-        break;
-    case PS_TYPE_OTHER:
-        break;
-    default:
-        psError(__func__, " : Line %d - Invalid vector type. Type: %d\n", __LINE__, vecType);
+    if (psVec->type.type == PS_TYPE_PTR) {
+        psLogMsg(__func__,PS_LOG_WARN,"psVectorFree was called with a void* vector. "
+                 "Referenced of pointers was not freed.");
+        psVoidPtrVectorFree(psVec,NULL);
+    } else {
+        psFree(psVec->vec.v);
+        psFree(psVec);
     }
-
-    // Free vector struct
-    psFree(psVec);
 }
 
-psVector* psVoidPtrVectorAlloc(int nalloc)
+void psVectorElementFree(psVector *restrict psVec, void (*elemFree)(void *))
 {
-    psVector *psVec = NULL;
-    psVec = psAlloc(sizeof(psVector));
-    psVec->vec.vp = p_psVectorAlloc(psVec, PS_TYPE_OTHER, nalloc, sizeof(void *));
-    return psVec;
-}
-
-psVector *psVoidPtrVectorRealloc(psVector *restrict psVec, int nalloc)
-{
-    int i = 0;
-
-    for (i = nalloc; i < psVec->n; i++) {               // For reduction in vector size
-        psMemDecrRefCounter(psVec->vec.vp[i]);
-    }
-
-    if(psVec == NULL) {                                 // For creating new psVector
-        psVec = psVoidPtrVectorAlloc(nalloc);
-    } else if(psVec->nalloc != nalloc) {                // No need to realloc to same size
-        psVec->vec.vp = p_psVectorRealloc(psVec, psVec->vec.vp, nalloc, sizeof(void *));
-    }
-
-    return psVec;
-}
-
-void psVoidPtrVectorFree(psVector *restrict psVec, void (*elemFree)(void *))
-{
-    int i = 0;
 
     if(psVec == NULL) {
@@ -297,5 +154,10 @@
     }
 
-    for(i = 0; i < psVec->nalloc; i++) {
+    if (psVec->type.type != PS_TYPE_PTR) {
+        psLogMsg(__func__,PS_LOG_WARN,"psVectorElementFree only operates on void* vectors");
+        return;
+    }
+
+    for(int i = 0; i < psVec->nalloc; i++) {
         if(elemFree == NULL) {
             psMemDecrRefCounter(psVec->vec.vp[i]);
@@ -303,9 +165,6 @@
             elemFree(psMemDecrRefCounter(psVec->vec.vp[i]));
         }
+        psVec->vec.vp[i] = NULL;
     }
-
-    // Free pointer vector
-    psFree(psVec->vec.vp);
-    psFree(psVec);
 }
 
Index: /trunk/psLib/src/collections/psVector.h
===================================================================
--- /trunk/psLib/src/collections/psVector.h	(revision 669)
+++ /trunk/psLib/src/collections/psVector.h	(revision 670)
@@ -19,6 +19,6 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-05-13 19:54:26 $
+ *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-13 22:47:52 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -60,5 +60,5 @@
     PS_TYPE_COMPLEX_FLOAT = 0x84,     ///< Complex numbers consisting of single-precision floating point.
     PS_TYPE_COMPLEX_DOUBLE = 0x88,    ///< Complex numbers consisting of double-precision floating point.
-    PS_TYPE_OTHER,                    ///< Something else that's not supported for arithmetic.} psElemType;
+    PS_TYPE_PTR = 0x00,               ///< Something else that's not supported for arithmetic.}
 } psElemType;
 
@@ -118,4 +118,5 @@
         double *d;                      ///< Pointers to double precision data.
         complex float *cf;              ///< Pointers to complex floating point data.
+        void *v;                        ///< Pointers to generic void data
         void **vp;                      ///< Void pointer vector.
     }vec;                               ///< Union for data types.
@@ -135,6 +136,6 @@
  */
 psVector *psVectorAlloc(
-    psElemType dataType,    ///< Type of data to be held by vector.
-    int nalloc              ///< Total number of elements to make available.
+    psElemType dataType,                ///< Type of data to be held by vector.
+    unsigned int nalloc                 ///< Total number of elements to make available.
 );
 
@@ -164,39 +165,11 @@
 );
 
-/** Allocate a void pointer vector.
+
+/** Deallocate/Dereference elements of a void pointer vector.
  *
- * Uses psLib memory allocation functions to create a vector of void pointers as defined by the psVoidPtrVector
- * struct.
- *
- * @return psVector*: Pointer to psVector.
- *
- */
-psVector *psVoidPtrVectorAlloc(
-    unsigned int nalloc                 ///< Number of elements to use.
-);
-
-/** Reallocate a void pointer vector.
- *
- * Uses psLib memory allocation functions to reallocate a vector of void pointers as defined by the
- * psVoidPtrVector struct. If the vector size is increased or decreased, this function does not allocate or
- * deallocate the contents of individual vector elements. The user must do this after calling this function.
- *
- * @return psVector*: Pointer to psVector.
- *
- */
-psVector *psVoidPtrVectorRealloc(
-    psVector *restrict psVec,           ///< Void pointer vector to destroy.
-    unsigned int nalloc                 ///< Number of elements.
-);
-
-/** Deallocate a void pointer vector.
- *
- * Uses psLib memory allocation functions to deallocate a vector of void pointers as defined by the
- * psVoidPtrVector struct. This function does not free the vector elements unless the user provides a callback
- * function. NULL may be passed as an alternative to supplying a callback, but the user must remember to
- * delete the vector elements afterwards. The user must not delete or deallocate the vector elements prior to
- * calling this function, as it requires valid elements for memory reference decrementation operations.
- *
- * @return: void
+ * Uses psLib memory allocation functions to deallocate/dereference elements of a vector of void pointers.
+ * This function does not free the vector elements unless the user provides a elemFree function
+ * pointer. If the elemFree function pointer is NULL, the reference cound of the elements are decremented
+ * without being freed.  The vector psVec is not freed, and its elements will all be set to NULL.
  *
  */
Index: /trunk/psLib/src/mathtypes/psVector.c
===================================================================
--- /trunk/psLib/src/mathtypes/psVector.c	(revision 669)
+++ /trunk/psLib/src/mathtypes/psVector.c	(revision 670)
@@ -3,5 +3,5 @@
  *  @brief Contains support for basic vector types
  *
- *  This file defines types and functions for one dimensional vectors which include: 
+ *  This file defines types and functions for one dimensional vectors which include:
  *      char
  *      short
@@ -19,6 +19,6 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-05-13 20:25:00 $
+ *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-13 22:47:52 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -31,4 +31,5 @@
 #include "psError.h"
 #include "psVector.h"
+#include "psLogMsg.h"
 
 /******************************************************************************/
@@ -60,7 +61,26 @@
 /*****************************************************************************/
 
-static void* p_psVectorAlloc(psVector *restrict psVec, psElemType elemType, int nalloc, int elemSize)
+/*****************************************************************************/
+/* FUNCTION IMPLEMENTATION - PUBLIC                                          */
+/*****************************************************************************/
+psVector* psVectorAlloc(psElemType elemType, unsigned int nalloc)
 {
-    void *vec = NULL;
+    psVector *psVec = NULL;
+    int elementSize = 0;
+
+    // Invalid nalloc
+    if(nalloc < 1) {
+        psError(__func__, "Invalid value for nalloc. nalloc: %d\n", nalloc);
+        return NULL;
+    }
+
+    if (elemType == PS_TYPE_PTR) {
+        elementSize = sizeof(void*);
+    } else {
+        elementSize = PSELEMTYPE_SIZEOF(elemType);
+    }
+
+    // Create vector struct
+    psVec = (psVector *)psAlloc(sizeof(psVector));
 
     psVec->type.dimen = PS_DIMEN_VECTOR;
@@ -69,139 +89,40 @@
     psVec->n = 0;
 
-    if(nalloc != 0) {
-        vec = psAlloc(nalloc*sizeof(elemSize));
-    }
+    // Create vector data array
+    psVec->vec.v = psAlloc(nalloc*elementSize);
 
-    return vec;
+    return psVec;
 }
 
-static void* p_psVectorRealloc(psVector *restrict psVec, void *vec, int nalloc, int elemSize)
+psVector *psVectorRealloc(psVector *restrict psVec, unsigned int nalloc)
 {
-    // For decrease in psVector size
-    if(nalloc < psVec->n) {
-        psVec->n = nalloc;
-    }
-
-    psVec->nalloc = nalloc;
-
-    return psRealloc(vec, nalloc*elemSize);
-}
-
-/*****************************************************************************/
-/* FUNCTION IMPLEMENTATION - PUBLIC                                          */
-/*****************************************************************************/
-psVector* psVectorAlloc(psElemType elemType, int nalloc)
-{
-    psVector *psVec = NULL;
-    psElemType vecType = 0;
-
-    vecType = elemType;
+    int elementSize = 0;
+    psElemType elemType = psVec->type.type;
 
     // Invalid nalloc
-    if(nalloc <= 0) {
+    if(nalloc < 1) {
         psError(__func__, " : Line %d - Invalid value for nalloc. nalloc: %d\n", __LINE__, nalloc);
         return NULL;
     }
 
-    // Create vector struct
-    psVec = (psVector *)psAlloc(sizeof(psVector));
-
-    // Create vector data array
-    switch(vecType) {
-    case PS_TYPE_CHAR:
-        psVec->vec.c = (char *)p_psVectorAlloc(psVec, PS_TYPE_CHAR, nalloc, sizeof(char));
-        break;
-    case PS_TYPE_SHORT:
-        psVec->vec.s = (short *)p_psVectorAlloc(psVec, PS_TYPE_SHORT, nalloc, sizeof(short));
-        break;
-    case PS_TYPE_INT:
-        psVec->vec.i = (int *)p_psVectorAlloc(psVec, PS_TYPE_INT, nalloc, sizeof(int));
-        break;
-    case PS_TYPE_LONG:
-        psVec->vec.l = (long *)p_psVectorAlloc(psVec, PS_TYPE_LONG, nalloc, sizeof(long));
-        break;
-    case PS_TYPE_UCHAR:
-        psVec->vec.uc = (unsigned char *)p_psVectorAlloc(psVec, PS_TYPE_UCHAR, nalloc, sizeof(unsigned char));
-        break;
-    case PS_TYPE_USHORT:
-        psVec->vec.us = (unsigned short *)p_psVectorAlloc(psVec, PS_TYPE_USHORT, nalloc, sizeof(unsigned short));
-        break;
-    case PS_TYPE_UINT:
-        psVec->vec.ui = (unsigned int *)p_psVectorAlloc(psVec, PS_TYPE_UINT, nalloc, sizeof(unsigned int));
-        break;
-    case PS_TYPE_ULONG:
-        psVec->vec.ul = (unsigned long *)p_psVectorAlloc(psVec, PS_TYPE_ULONG, nalloc, sizeof(unsigned long));
-        break;
-    case PS_TYPE_FLOAT:
-        psVec->vec.f = (float *)p_psVectorAlloc(psVec, PS_TYPE_FLOAT, nalloc, sizeof(float));
-        break;
-    case PS_TYPE_DOUBLE:
-        psVec->vec.d = (double *)p_psVectorAlloc(psVec, PS_TYPE_DOUBLE, nalloc, sizeof(double));
-        break;
-    case PS_TYPE_COMPLEX:
-        psVec->vec.cf = (complex float *)p_psVectorAlloc(psVec, PS_TYPE_COMPLEX, nalloc, sizeof(complex float));
-        break;
-    case PS_TYPE_OTHER:
-        break;
-    default:
-        psError(__func__, " : Line %d - Invalid vector type. Type: %d\n", __LINE__, vecType);
+    if (elemType == PS_TYPE_PTR) {
+        elementSize = sizeof(void*);
+    } else {
+        elementSize = PSELEMTYPE_SIZEOF(elemType);
     }
 
-    return psVec;
-}
-
-psVector *psVectorRealloc(psVector *restrict psVec, int nalloc)
-{
-    psElemType vecType = 0;
-
-    vecType = psVec->type.type;
-
-    // Invalid nalloc
-    if(nalloc < 0) {
-        psError(__func__, " : Line %d - Invalid value for nalloc. nalloc: %d\n", __LINE__, nalloc);
-        return NULL;
-    }
 
     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
-        switch (vecType) {
-        case PS_TYPE_CHAR:
-            psVec->vec.c = p_psVectorRealloc(psVec, psVec->vec.c, nalloc, sizeof(char));
-            break;
-        case PS_TYPE_SHORT:
-            psVec->vec.s = p_psVectorRealloc(psVec, psVec->vec.s, nalloc, sizeof(short));
-            break;
-        case PS_TYPE_INT:
-            psVec->vec.i = p_psVectorRealloc(psVec, psVec->vec.i, nalloc, sizeof(int));
-            break;
-        case PS_TYPE_LONG:
-            psVec->vec.l = p_psVectorRealloc(psVec, psVec->vec.l, nalloc, sizeof(long));
-            break;
-        case PS_TYPE_UCHAR:
-            psVec->vec.uc = p_psVectorRealloc(psVec, psVec->vec.uc, nalloc, sizeof(unsigned char));
-            break;
-        case PS_TYPE_USHORT:
-            psVec->vec.us = p_psVectorRealloc(psVec, psVec->vec.us, nalloc, sizeof(unsigned short));
-            break;
-        case PS_TYPE_UINT:
-            psVec->vec.ui = p_psVectorRealloc(psVec, psVec->vec.ui, nalloc, sizeof(unsigned int));
-            break;
-        case PS_TYPE_ULONG:
-            psVec->vec.ul = p_psVectorRealloc(psVec, psVec->vec.ul, nalloc, sizeof(unsigned long));
-            break;
-        case PS_TYPE_FLOAT:
-            psVec->vec.f = p_psVectorRealloc(psVec, psVec->vec.f, nalloc, sizeof(float));
-            break;
-        case PS_TYPE_DOUBLE:
-            psVec->vec.d = p_psVectorRealloc(psVec, psVec->vec.d, nalloc, sizeof(double));
-            break;
-        case PS_TYPE_COMPLEX:
-            psVec->vec.cf = p_psVectorRealloc(psVec, psVec->vec.cf, nalloc, sizeof(complex float));
-            break;
-        case PS_TYPE_OTHER:
-            break;
-        default:
-            psError(__func__, " : Line %d - Invalid vector type. Type: %d\n", __LINE__, vecType);
+        psVec->vec.v = psRealloc(psVec->vec.v,nalloc*elementSize);
+        psVec->nalloc = nalloc;
+        if(nalloc < psVec->n) {
+            if (elemType == PS_TYPE_PTR) {
+                for (int i = nalloc; i < psVec->n; i++) {               // For reduction in vector size
+                    psMemDecrRefCounter(psVec->vec.vp[i]);
+                }
+            }
+            psVec->n = nalloc;
         }
     }
@@ -212,84 +133,20 @@
 void psVectorFree(psVector *restrict psVec)
 {
-    psElemType vecType = 0;
-
-    vecType = psVec->type.type;
-
     if (psVec == NULL) {
         return;
     }
 
-    switch (vecType) {
-    case PS_TYPE_CHAR:
-        psFree(psVec->vec.c);
-        break;
-    case PS_TYPE_SHORT:
-        psFree(psVec->vec.s);
-        break;
-    case PS_TYPE_INT:
-        psFree(psVec->vec.i);
-        break;
-    case PS_TYPE_LONG:
-        psFree(psVec->vec.l);
-        break;
-    case PS_TYPE_UCHAR:
-        psFree(psVec->vec.uc);
-        break;
-    case PS_TYPE_USHORT:
-        psFree(psVec->vec.us);
-        break;
-    case PS_TYPE_UINT:
-        psFree(psVec->vec.ui);
-        break;
-    case PS_TYPE_ULONG:
-        psFree(psVec->vec.ul);
-        break;
-    case PS_TYPE_FLOAT:
-        psFree(psVec->vec.f);
-        break;
-    case PS_TYPE_DOUBLE:
-        psFree(psVec->vec.d);
-        break;
-    case PS_TYPE_COMPLEX:
-        psFree(psVec->vec.cf);
-        break;
-    case PS_TYPE_OTHER:
-        break;
-    default:
-        psError(__func__, " : Line %d - Invalid vector type. Type: %d\n", __LINE__, vecType);
+    if (psVec->type.type == PS_TYPE_PTR) {
+        psLogMsg(__func__,PS_LOG_WARN,"psVectorFree was called with a void* vector. "
+                 "Referenced of pointers was not freed.");
+        psVoidPtrVectorFree(psVec,NULL);
+    } else {
+        psFree(psVec->vec.v);
+        psFree(psVec);
     }
-
-    // Free vector struct
-    psFree(psVec);
 }
 
-psVector* psVoidPtrVectorAlloc(int nalloc)
+void psVectorElementFree(psVector *restrict psVec, void (*elemFree)(void *))
 {
-    psVector *psVec = NULL;
-    psVec = psAlloc(sizeof(psVector));
-    psVec->vec.vp = p_psVectorAlloc(psVec, PS_TYPE_OTHER, nalloc, sizeof(void *));
-    return psVec;
-}
-
-psVector *psVoidPtrVectorRealloc(psVector *restrict psVec, int nalloc)
-{
-    int i = 0;
-
-    for (i = nalloc; i < psVec->n; i++) {               // For reduction in vector size
-        psMemDecrRefCounter(psVec->vec.vp[i]);
-    }
-
-    if(psVec == NULL) {                                 // For creating new psVector
-        psVec = psVoidPtrVectorAlloc(nalloc);
-    } else if(psVec->nalloc != nalloc) {                // No need to realloc to same size
-        psVec->vec.vp = p_psVectorRealloc(psVec, psVec->vec.vp, nalloc, sizeof(void *));
-    }
-
-    return psVec;
-}
-
-void psVoidPtrVectorFree(psVector *restrict psVec, void (*elemFree)(void *))
-{
-    int i = 0;
 
     if(psVec == NULL) {
@@ -297,5 +154,10 @@
     }
 
-    for(i = 0; i < psVec->nalloc; i++) {
+    if (psVec->type.type != PS_TYPE_PTR) {
+        psLogMsg(__func__,PS_LOG_WARN,"psVectorElementFree only operates on void* vectors");
+        return;
+    }
+
+    for(int i = 0; i < psVec->nalloc; i++) {
         if(elemFree == NULL) {
             psMemDecrRefCounter(psVec->vec.vp[i]);
@@ -303,9 +165,6 @@
             elemFree(psMemDecrRefCounter(psVec->vec.vp[i]));
         }
+        psVec->vec.vp[i] = NULL;
     }
-
-    // Free pointer vector
-    psFree(psVec->vec.vp);
-    psFree(psVec);
 }
 
Index: /trunk/psLib/src/mathtypes/psVector.h
===================================================================
--- /trunk/psLib/src/mathtypes/psVector.h	(revision 669)
+++ /trunk/psLib/src/mathtypes/psVector.h	(revision 670)
@@ -19,6 +19,6 @@
  *  @author Ross Harman, MHPCC
  *   
- *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-05-13 19:54:26 $
+ *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-05-13 22:47:52 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -60,5 +60,5 @@
     PS_TYPE_COMPLEX_FLOAT = 0x84,     ///< Complex numbers consisting of single-precision floating point.
     PS_TYPE_COMPLEX_DOUBLE = 0x88,    ///< Complex numbers consisting of double-precision floating point.
-    PS_TYPE_OTHER,                    ///< Something else that's not supported for arithmetic.} psElemType;
+    PS_TYPE_PTR = 0x00,               ///< Something else that's not supported for arithmetic.}
 } psElemType;
 
@@ -118,4 +118,5 @@
         double *d;                      ///< Pointers to double precision data.
         complex float *cf;              ///< Pointers to complex floating point data.
+        void *v;                        ///< Pointers to generic void data
         void **vp;                      ///< Void pointer vector.
     }vec;                               ///< Union for data types.
@@ -135,6 +136,6 @@
  */
 psVector *psVectorAlloc(
-    psElemType dataType,    ///< Type of data to be held by vector.
-    int nalloc              ///< Total number of elements to make available.
+    psElemType dataType,                ///< Type of data to be held by vector.
+    unsigned int nalloc                 ///< Total number of elements to make available.
 );
 
@@ -164,39 +165,11 @@
 );
 
-/** Allocate a void pointer vector.
+
+/** Deallocate/Dereference elements of a void pointer vector.
  *
- * Uses psLib memory allocation functions to create a vector of void pointers as defined by the psVoidPtrVector
- * struct.
- *
- * @return psVector*: Pointer to psVector.
- *
- */
-psVector *psVoidPtrVectorAlloc(
-    unsigned int nalloc                 ///< Number of elements to use.
-);
-
-/** Reallocate a void pointer vector.
- *
- * Uses psLib memory allocation functions to reallocate a vector of void pointers as defined by the
- * psVoidPtrVector struct. If the vector size is increased or decreased, this function does not allocate or
- * deallocate the contents of individual vector elements. The user must do this after calling this function.
- *
- * @return psVector*: Pointer to psVector.
- *
- */
-psVector *psVoidPtrVectorRealloc(
-    psVector *restrict psVec,           ///< Void pointer vector to destroy.
-    unsigned int nalloc                 ///< Number of elements.
-);
-
-/** Deallocate a void pointer vector.
- *
- * Uses psLib memory allocation functions to deallocate a vector of void pointers as defined by the
- * psVoidPtrVector struct. This function does not free the vector elements unless the user provides a callback
- * function. NULL may be passed as an alternative to supplying a callback, but the user must remember to
- * delete the vector elements afterwards. The user must not delete or deallocate the vector elements prior to
- * calling this function, as it requires valid elements for memory reference decrementation operations.
- *
- * @return: void
+ * Uses psLib memory allocation functions to deallocate/dereference elements of a vector of void pointers.
+ * This function does not free the vector elements unless the user provides a elemFree function
+ * pointer. If the elemFree function pointer is NULL, the reference cound of the elements are decremented
+ * without being freed.  The vector psVec is not freed, and its elements will all be set to NULL.
  *
  */
