Index: /trunk/psLib/src/astro/psCoord.c
===================================================================
--- /trunk/psLib/src/astro/psCoord.c	(revision 9729)
+++ /trunk/psLib/src/astro/psCoord.c	(revision 9730)
@@ -10,6 +10,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.125 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-10-13 22:04:58 $
+*  @version $Revision: 1.126 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-10-24 22:52:55 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -795,13 +795,9 @@
     psVector *xOut = psVectorAlloc(numCoords, PS_TYPE_F64);
     psVector *yOut = psVectorAlloc(numCoords, PS_TYPE_F64);
-    for (psS32 g = 0; g < numCoords; g++) {
+    for (int g = 0; g < numCoords; g++) {
         xIn->data.F64[g] = ((psPlane *) source->data[g])->x;
-        xIn->n++;
         yIn->data.F64[g] = ((psPlane *) source->data[g])->y;
-        yIn->n++;
         xOut->data.F64[g] = ((psPlane *) dest->data[g])->x;
-        xOut->n++;
         yOut->data.F64[g] = ((psPlane *) dest->data[g])->y;
-        yOut->n++;
     }
 
Index: /trunk/psLib/src/db/psDB.c
===================================================================
--- /trunk/psLib/src/db/psDB.c	(revision 9729)
+++ /trunk/psLib/src/db/psDB.c	(revision 9730)
@@ -12,6 +12,6 @@
  *  @author Joshua Hoblitt
  *
- *  @version $Revision: 1.106 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-21 01:09:37 $
+ *  @version $Revision: 1.107 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:52:55 $
  *
  *  Copyright (C) 2005-2006  Joshua Hoblitt, University of Hawaii
@@ -395,6 +395,5 @@
     // then reset n to 0 so elements are added from the beginning of
     // the array
-    column = psArrayAlloc(rowCount);
-    column->n = 0;
+    column = psArrayAllocEmpty(rowCount);
 
     // Fetch each result
@@ -459,51 +458,39 @@
 
     psVector *column = psVectorAlloc(stringColumn->n, type);
-    //    column->n = column->nalloc;
 
     // conversion functions are a portability issue
     switch (type) {
     case PS_TYPE_S8:
-        column->n = column->nalloc;
         PS_STR_ARRAY_TO_PTYPE(column->data.S8, stringColumn, atoi, psS8, PS_TYPE_S8);
         break;
     case PS_TYPE_S16:
-        column->n = column->nalloc;
         PS_STR_ARRAY_TO_PTYPE(column->data.S16, stringColumn, atoi, psS16, PS_TYPE_S16);
         break;
     case PS_TYPE_S32:
-        column->n = column->nalloc;
         PS_STR_ARRAY_TO_PTYPE(column->data.S32, stringColumn, atoi, psS32, PS_TYPE_S32);
         break;
     case PS_TYPE_S64:
-        column->n = column->nalloc;
         PS_STR_ARRAY_TO_PTYPE(column->data.S64, stringColumn, atoll, psS64, PS_TYPE_S64);
         break;
     case PS_TYPE_U8:
-        column->n = column->nalloc;
         PS_STR_ARRAY_TO_PTYPE(column->data.U8, stringColumn, atoi, psU8, PS_TYPE_U8);
         break;
     case PS_TYPE_U16:
-        column->n = column->nalloc;
         PS_STR_ARRAY_TO_PTYPE(column->data.U16, stringColumn, atoi, psU16, PS_TYPE_U16);
         break;
     case PS_TYPE_U32:
-        column->n = column->nalloc;
         PS_STR_ARRAY_TO_PTYPE(column->data.U32, stringColumn, atoi, psU32, PS_TYPE_U32);
         break;
     case PS_TYPE_U64:
-        column->n = column->nalloc;
         PS_STR_ARRAY_TO_PTYPE(column->data.U64, stringColumn, atoll, psU64, PS_TYPE_U64);
         break;
     case PS_TYPE_F32:
-        column->n = column->nalloc;
         PS_STR_ARRAY_TO_PTYPE(column->data.F32, stringColumn, atof, psF32, PS_TYPE_F32);
         break;
     case PS_TYPE_F64:
-        column->n = column->nalloc;
         PS_STR_ARRAY_TO_PTYPE(column->data.F64, stringColumn, atof, psF64, PS_TYPE_F64);
         break;
     case PS_TYPE_C32:
         // this is a bogus SQL type
-        column->n = column->nalloc;
         PS_STR_ARRAY_TO_PTYPE(column->data.C32, stringColumn, atof, psC32, PS_TYPE_C32);
         break;
@@ -514,5 +501,4 @@
     case PS_TYPE_BOOL:
         // valid for psVector?
-        column->n = column->nalloc;
         PS_STR_ARRAY_TO_PTYPE(column->data.U8, stringColumn, atoi, psU8, PS_TYPE_U8);
         break;
@@ -567,6 +553,5 @@
 
     // Create array to store single row
-    psArray *rowSet = psArrayAlloc(1);
-    rowSet->n = 0;
+    psArray *rowSet = psArrayAllocEmpty(1);
     psArrayAdd(rowSet, 0, (psPtr)row);
 
@@ -697,5 +682,5 @@
     }
 
-    psArray *rowData = psArrayAlloc(1);
+    psArray *rowData = psArrayAllocEmpty(1);
     psArrayAdd(rowData, 0, values);
     long rowsAffected = p_psDBRunQueryPrepared(dbh, rowData, query);
@@ -966,5 +951,5 @@
     // then reset n to 0 so elements are added from the beginning of
     // the array
-    resultSet = psArrayAlloc(rowCount);
+    resultSet = psArrayAllocEmpty(rowCount);
 
     field = mysql_fetch_fields(result);
@@ -1304,5 +1289,5 @@
     // Reset iterator to head of list
     psListIteratorSet(cursor, 0);
-    psArray *pKeys = psArrayAlloc(1);
+    psArray *pKeys = psArrayAllocEmpty(1);
     while ((item = psListGetAndIncrement(cursor))) {
         if (strstr(item->comment, "Primary Key")) {
Index: /trunk/psLib/src/fits/psFitsImage.c
===================================================================
--- /trunk/psLib/src/fits/psFitsImage.c	(revision 9729)
+++ /trunk/psLib/src/fits/psFitsImage.c	(revision 9730)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-13 21:13:47 $
+ *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:52:55 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -519,5 +519,4 @@
     if (nAxis == 2) {
         psArray *images = psArrayAlloc(1); // Single image plane
-        images->n = 1;
         images->data[0] = psFitsReadImage(fits, region, 0);
         return images;
@@ -533,5 +532,4 @@
 
         psArray *images = psArrayAlloc(nAxes[2]); // Array of image planes
-        images->n = nAxes[2];
         for (int i = 0; i < nAxes[2]; i++) {
             images->data[i] = psFitsReadImage(fits, region, i);
Index: /trunk/psLib/src/fits/psFitsTable.c
===================================================================
--- /trunk/psLib/src/fits/psFitsTable.c	(revision 9729)
+++ /trunk/psLib/src/fits/psFitsTable.c	(revision 9730)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-08-26 04:34:28 $
+ *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:52:55 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -237,5 +237,4 @@
         result->data[row] = psAlloc((width+1)*sizeof(char));
     }
-    result->n = numRows;
 
     fits_read_col_str(fits->fd,
@@ -319,5 +318,4 @@
 
     psVector* result = psVectorAlloc(numRows, p_psFitsTypeFromCfitsio(typecode));
-    result->n = numRows;
 
     fits_read_col(fits->fd,
@@ -389,5 +387,4 @@
         psTrace("psLib.fits",5,"Reading row %i of %li\n",row, numRows);
         table->data[row] = psFitsReadTableRow(fits,row);
-        table->n++;
     }
 
@@ -564,6 +561,4 @@
     psArray *columnNames = psArrayAlloc(numColumns); // Array of column names, for cfitsio
     psArray *columnTypes = psArrayAlloc(numColumns); // Array of column types, for cfitsio
-    columnNames->n = numColumns;
-    columnTypes->n = numColumns;
     psMetadataIterator *colSpecsIter = psMetadataIteratorAlloc(colSpecs, PS_LIST_HEAD, NULL); // Iterator
     psMetadataItem *colSpecItem;        // Column specification item, from iteration
@@ -644,5 +639,4 @@
             size_t dataSize = PSELEMTYPE_SIZEOF(spec->type); // Size (in bytes) of this type
             psVector *columnData = psVectorAlloc(table->n, spec->type); // The raw row data, to be written
-            columnData->n = table->n;
             psVectorInit(columnData, 0);
             for (long i = 0; i < table->n; i++) {
@@ -667,5 +661,4 @@
             case PS_DATA_STRING: {
                     psArray *strings = psArrayAlloc(table->n); // Array of strings
-                    strings->n = table->n;
                     for (long i = 0; i < table->n; i++) {
                         psMetadata *row = table->data[i]; // The row of interest
Index: /trunk/psLib/src/imageops/psImageBackground.c
===================================================================
--- /trunk/psLib/src/imageops/psImageBackground.c	(revision 9729)
+++ /trunk/psLib/src/imageops/psImageBackground.c	(revision 9730)
@@ -36,5 +36,5 @@
     int Npixels = nx*ny;                // Total number of pixels
 
-    psVector *values = psVectorAlloc(Nsubset, PS_TYPE_F32); // Vector containing subsample
+    psVector *values = psVectorAllocEmpty(Nsubset, PS_TYPE_F32); // Vector containing subsample
 
     // Minimum and maximum values
Index: /trunk/psLib/src/imageops/psImageConvolve.c
===================================================================
--- /trunk/psLib/src/imageops/psImageConvolve.c	(revision 9729)
+++ /trunk/psLib/src/imageops/psImageConvolve.c	(revision 9730)
@@ -5,6 +5,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-13 21:13:48 $
+ *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:52:55 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -505,5 +505,4 @@
         /* generate normalized gaussian */ \
         psVector *gaussnorm = psVectorAlloc(Npixel, PS_TYPE_##TYPE); \
-        gaussnorm->n = gaussnorm->nalloc; \
         { \
             double sum = 0.0; \
@@ -522,5 +521,4 @@
         { \
             psVector *calculation = psVectorAlloc(Nx, PS_TYPE_##TYPE); \
-            calculation->n = calculation->nalloc; \
             for (int j = 0; j < Ny; j++) { \
                 ps##TYPE *vi = image->data.TYPE[j]; \
@@ -573,5 +571,4 @@
         /* Smooth in Y direction */ \
         psArray *rows = psArrayAlloc(Nrange); \
-        rows->n = Nrange; \
         /* Smooth the first Nrange pixels, with renorm */ \
         int yMax = PS_MIN(Nrange, Ny); \
@@ -579,5 +576,4 @@
         for (int j = 0; j < yMax; j++) { \
             psVector *calculation = psVectorAlloc(Nx, PS_TYPE_##TYPE); \
-            calculation->n = calculation->nalloc; \
             /* Zero the output row */ \
             memset(calculation->data.TYPE, 0, Nx*sizeof(ps##TYPE)); \
Index: /trunk/psLib/src/imageops/psImageGeomManip.c
===================================================================
--- /trunk/psLib/src/imageops/psImageGeomManip.c	(revision 9729)
+++ /trunk/psLib/src/imageops/psImageGeomManip.c	(revision 9730)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-08-08 23:32:23 $
+ *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:52:55 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -80,5 +80,5 @@
     }
 
-    vec = psVectorAlloc(scale * scale, in->type.type);
+    vec = psVectorAllocEmpty(scale * scale, in->type.type);
 
     if (mask != NULL) {
@@ -93,6 +93,5 @@
             return NULL;
         }
-        maskVec = psVectorAlloc(scale * scale, PS_TYPE_MASK);
-        maskVec->n = maskVec->nalloc;
+        maskVec = psVectorAllocEmpty(scale * scale, PS_TYPE_MASK);
         maskData = maskVec->data.PS_TYPE_MASK_DATA;
     }
@@ -134,4 +133,5 @@
                 } \
                 vec->n = n; \
+                maskVec->n = n; \
                 myStats = psVectorStats(myStats, vec, NULL, maskVec, maskVal); \
                 outRowData[col] = (ps##TYPE)psStatsGetValue(myStats, statistic); \
Index: /trunk/psLib/src/imageops/psImagePixelExtract.c
===================================================================
--- /trunk/psLib/src/imageops/psImagePixelExtract.c	(revision 9729)
+++ /trunk/psLib/src/imageops/psImagePixelExtract.c	(revision 9730)
@@ -8,6 +8,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-08-26 04:34:28 $
+ *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:52:55 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -18,4 +18,5 @@
 
 #include "psMemory.h"
+#include "psVector.h"
 #include "psImagePixelExtract.h"
 #include "psError.h"
@@ -392,5 +393,4 @@
     if (direction == PS_CUT_X_POS || direction == PS_CUT_X_NEG) {
         psVector* imgVec = psVectorAlloc(numRows, type);
-        imgVec->n = imgVec->nalloc;
         psVector* maskVec = NULL;
         psMaskType* maskData = NULL;
@@ -417,5 +417,4 @@
         if (mask != NULL) {
             maskVec = psVectorAlloc(numRows, mask->type.type);
-            maskVec->n = maskVec->nalloc;
         }
         #define PSIMAGE_CUT_VERTICAL(TYPE) \
@@ -855,13 +854,11 @@
         // n.b. alloc enough for the data by making the vectors slightly larger
         // than the area of the region of interest.
-        buffer[lcv] = psVectorAlloc(1+4*(rSq[lcv+1]-rSq[lcv]),
-                                    input->type.type);
-        buffer[lcv]->n = 0;
+        buffer[lcv] = psVectorAllocEmpty(1+4*(rSq[lcv+1]-rSq[lcv]),
+                                         input->type.type);
 
         bufferMask[lcv] = NULL;
         if (mask != NULL) {
-            bufferMask[lcv] = psVectorAlloc(1+4*(rSq[lcv+1]-rSq[lcv]),
-                                            PS_TYPE_MASK);
-            bufferMask[lcv]->n = 0;
+            bufferMask[lcv] = psVectorAllocEmpty(1+4*(rSq[lcv+1]-rSq[lcv]),
+                                                 PS_TYPE_MASK);
         }
     }
Index: /trunk/psLib/src/imageops/psImageStats.c
===================================================================
--- /trunk/psLib/src/imageops/psImageStats.c	(revision 9729)
+++ /trunk/psLib/src/imageops/psImageStats.c	(revision 9730)
@@ -9,6 +9,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.100 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-08-26 04:34:28 $
+ *  @version $Revision: 1.101 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:52:55 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -76,5 +76,4 @@
 
         junkData = psVectorAlloc(numRows*numCols, in->type.type);
-        junkData->n = junkData->nalloc;
 
         psU8* data = junkData->data.U8;
@@ -100,5 +99,4 @@
 
             junkMask = psVectorAlloc(numRows*numCols, mask->type.type);
-            junkMask->n = junkMask->nalloc;
 
             psU8* data = junkMask->data.U8;
@@ -149,5 +147,4 @@
 
         junkData = psVectorAlloc(numRows*numCols, in->type.type);
-        junkData->n = junkData->nalloc;
 
         psU8* data = junkData->data.U8;
@@ -173,5 +170,4 @@
 
             junkMask = psVectorAlloc(numRows*numCols, mask->type.type);
-            junkMask->n = junkMask->nalloc;
 
             psU8* data = junkMask->data.U8;
@@ -592,9 +588,9 @@
         return -1;
     }/* else if (col0 == col1 && row0 == row1) {
-                                                psError(PS_ERR_BAD_PARAMETER_VALUE, true,
-                                                        "Invalid psRegion specified.  Region contains only 1 pixel.\n");
-                                                return -1;
-                                            }
-                                        */
+                                                    psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                                                            "Invalid psRegion specified.  Region contains only 1 pixel.\n");
+                                                    return -1;
+                                                }
+                                            */
     x0 = col0;
     x1 = col1;
Index: /trunk/psLib/src/jpeg/psImageJpeg.c
===================================================================
--- /trunk/psLib/src/jpeg/psImageJpeg.c	(revision 9729)
+++ /trunk/psLib/src/jpeg/psImageJpeg.c	(revision 9730)
@@ -33,8 +33,4 @@
     map->blue  = psVectorAlloc(256, PS_TYPE_U8);
     map->green = psVectorAlloc(256, PS_TYPE_U8);
-
-    map->red->n = 256;
-    map->blue->n = 256;
-    map->green->n = 256;
 
     return map;
Index: /trunk/psLib/src/math/psMinimizeLMM.c
===================================================================
--- /trunk/psLib/src/math/psMinimizeLMM.c	(revision 9729)
+++ /trunk/psLib/src/math/psMinimizeLMM.c	(revision 9730)
@@ -10,6 +10,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-14 00:15:47 $
+ *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:52:56 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -163,7 +163,5 @@
     psImage  *Alpha  = psImageAlloc (params->n, params->n, PS_TYPE_F64);
     psVector *beta   = psVectorAlloc(params->n, PS_TYPE_F64);
-    beta->n = beta->nalloc;
     psVector *Params = psVectorAlloc(params->n, PS_TYPE_F64);
-    Params->n = Params->nalloc;
     psVector *dy     = NULL;
     psBool rc = true;
@@ -175,5 +173,4 @@
     } else {
         dy = psVectorAlloc(y->n, PS_TYPE_F32);
-        dy->n = dy->nalloc;
         psVectorInit(dy, 1.0);
     }
@@ -246,5 +243,4 @@
     psF64 ymodel;
     psVector *deriv = psVectorAlloc(params->n, PS_TYPE_F32);
-    deriv->n = deriv->nalloc;
 
     // zero alpha and beta for summing below
@@ -380,9 +376,6 @@
     psImage *Alpha   = psImageAlloc(params->n, params->n, PS_TYPE_F64);
     psVector *beta   = psVectorAlloc(params->n, PS_TYPE_F64);
-    beta->n = beta->nalloc;
     psVector *Beta   = psVectorAlloc(params->n, PS_TYPE_F64);
-    beta->n = beta->nalloc;
     psVector *Params = psVectorAlloc(params->n, PS_TYPE_F32);
-    Params->n = Params->nalloc;
     psVector *dy     = NULL;
     psF64 Chisq = 0.0;
@@ -398,5 +391,4 @@
     } else {
         dy = psVectorAlloc(y->n, PS_TYPE_F32);
-        dy->n = dy->nalloc;
         psVectorInit(dy, 1.0);
     }
Index: /trunk/psLib/src/math/psMinimizePolyFit.c
===================================================================
--- /trunk/psLib/src/math/psMinimizePolyFit.c	(revision 9729)
+++ /trunk/psLib/src/math/psMinimizePolyFit.c	(revision 9730)
@@ -10,6 +10,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-19 02:57:18 $
+ *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:52:56 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -46,5 +46,4 @@
 #define PS_VECTOR_GEN_CHEBY_INDEX(VEC, SIZE, TYPE) \
 VEC = psVectorAlloc(SIZE, TYPE); \
-VEC->n = VEC->nalloc; \
 if (TYPE == PS_TYPE_F64) { \
     for (psS32 i = 0 ; i < SIZE ; i++) { \
@@ -93,8 +92,7 @@
     if (sums == NULL) {
         sums = psVectorAlloc(nSum, PS_TYPE_F64);
-        sums->n = sums->nalloc;
     } else if (nSum > sums->n) {
         sums = psVectorRealloc(sums, nSum);
-        sums->n = sums->nalloc;
+        sums->n = nSum;
     }
 
@@ -333,5 +331,4 @@
     psImage *A = psImageAlloc(numTerms, numTerms, PS_TYPE_F64); // Least-squares matrix
     psVector *B = psVectorAlloc(numTerms, PS_TYPE_F64); // Least-squares vector
-    B->n = numTerms;
     psImageInit(A, 0.0);
     psVectorInit(B, 0.0);
@@ -509,5 +506,4 @@
     psImage *A = psImageAlloc(nTerm, nTerm, PS_TYPE_F64); // Least-squares matrix
     psVector *B = psVectorAlloc(nTerm, PS_TYPE_F64); // Least-squares vector
-    B->n = B->nalloc;
 
     // Initialize data structures.
@@ -805,5 +801,4 @@
     psVector *fit   = NULL;
     psVector *resid = psVectorAlloc(f->n, PS_TYPE_F64);
-    resid->n = resid->nalloc;
 
     // eventual expansion: user supplies one of various stats option pairs,
@@ -976,5 +971,4 @@
     psImage *A = psImageAlloc(nTerm, nTerm, PS_TYPE_F64); // Least-squares matrix
     psVector *B = psVectorAlloc(nTerm, PS_TYPE_F64); // Least-squares vector
-    B->n = B->nalloc;
 
     // Initialize data structures.
@@ -1256,5 +1250,4 @@
     }
     psVector *resid = psVectorAlloc(f->n, PS_TYPE_F64);
-    resid->n = resid->nalloc;
 
     // eventual expansion: user supplies one of various stats option pairs,
@@ -1434,5 +1427,4 @@
     psImage    *A = psImageAlloc(nTerm, nTerm, PS_TYPE_F64); // Least-squares matrix
     psVector   *B = psVectorAlloc(nTerm, PS_TYPE_F64); // Least-squares vector
-    B->n = B->nalloc;
 
     // Initialize data structures.
@@ -1790,5 +1782,4 @@
     psVector *fit   = NULL;
     psVector *resid = psVectorAlloc(f->n, PS_TYPE_F64);
-    resid->n = resid->nalloc;
 
     // eventual expansion: user supplies one of various stats option pairs,
@@ -1967,5 +1958,4 @@
     psImage    *A = psImageAlloc(nTerm, nTerm, PS_TYPE_F64); // Least-squares matrix
     psVector   *B = psVectorAlloc(nTerm, PS_TYPE_F64); // Least-squares vector
-    B->n = B->nalloc;
 
     // Initialize data structures.
@@ -2368,5 +2358,4 @@
     psVector *fit   = NULL;
     psVector *resid = psVectorAlloc(f->n, PS_TYPE_F64);
-    resid->n = resid->nalloc;
 
     // eventual expansion: user supplies one of various stats option pairs,
Index: /trunk/psLib/src/math/psMinimizePowell.c
===================================================================
--- /trunk/psLib/src/math/psMinimizePowell.c	(revision 9729)
+++ /trunk/psLib/src/math/psMinimizePowell.c	(revision 9730)
@@ -11,6 +11,6 @@
  *  NOTE: XXX: The SDR is silent about data types.  F32 is implemented here.
  *
- *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-13 22:04:58 $
+ *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:52:56 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -549,7 +549,5 @@
                 ((psVector *) (v->data[i]))->data.F32[j] = 0.0;
             }
-            ((psVector *)(v->data[i]))->n++;
-        }
-        v->n++;
+        }
     }
 
Index: /trunk/psLib/src/math/psPolynomial.c
===================================================================
--- /trunk/psLib/src/math/psPolynomial.c	(revision 9729)
+++ /trunk/psLib/src/math/psPolynomial.c	(revision 9730)
@@ -7,6 +7,6 @@
 *  polynomials.  It also contains a Gaussian functions.
 *
-*  @version $Revision: 1.151 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-10-13 22:04:58 $
+*  @version $Revision: 1.152 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-10-24 22:52:56 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -266,5 +266,4 @@
         // General case where the Chebyshev poly has 2 or more terms.
         d = psVectorAlloc(nTerms, PS_TYPE_F64);
-        d->n = d->nalloc;
         if(poly->mask[nTerms-1] == 0) {
             d->data.F64[nTerms-1] = poly->coeff[nTerms-1];
@@ -571,32 +570,4 @@
     psTrace("psLib.math", 4, "---- %s() end ----\n", __func__);
     return(tmp * exp(-((x - mean) * (x - mean)) / (2.0 * sigma * sigma)));
-}
-
-/*****************************************************************************
-    p_psGaussianDev()
- This private routine (formerly a psLib API routine) creates a psVector of the
- specified size and type F32 and fills it with a random Gaussian distribution
- of numbers with the specified mean and sigma.
- 
-XXX: It's possible to have a different seed everytime.  However, for now,
-for testability, we use a common seed.
- *****************************************************************************/
-#define PS_XXX_GAUSSIAN_SEED 1995
-psVector* p_psGaussianDev(psF32 mean,
-                          psF32 sigma,
-                          unsigned int Npts)
-{
-    PS_ASSERT_INT_NONNEGATIVE(Npts, NULL);
-
-    //    psRandom *r = psRandomAlloc(PS_RANDOM_TAUS, p_psRandomGetSystemSeed());
-    psRandom *r = psRandomAlloc(PS_RANDOM_TAUS, PS_XXX_GAUSSIAN_SEED);
-    psVector* gauss = psVectorAlloc(Npts, PS_TYPE_F32);
-    for (unsigned int i = 0; i < Npts; i++) {
-        gauss->data.F32[i] = mean + p_psRandomGaussian(r, sigma);
-        gauss->n++;
-    }
-    psFree(r);
-
-    return(gauss);
 }
 
@@ -808,5 +779,4 @@
         for (unsigned int i=0;i<x->n;i++) {
             tmp->data.F64[i] = psPolynomial1DEval(poly, x->data.F64[i]);
-            tmp->n++;
         }
         break;
@@ -815,5 +785,4 @@
         for (unsigned int i=0;i<x->n;i++) {
             tmp->data.F32[i] = psPolynomial1DEval(poly, x->data.F32[i]);
-            tmp->n++;
         }
         break;
@@ -877,5 +846,4 @@
         for (unsigned int i=0; i<vecLen; i++) {
             tmp->data.F32[i] = psPolynomial2DEval(poly,x->data.F32[i],y->data.F32[i]);
-            tmp->n++;
         }
         break;
@@ -892,5 +860,4 @@
         for (unsigned int i=0; i<vecLen; i++) {
             tmp->data.F64[i] = psPolynomial2DEval(poly,x->data.F64[i],y->data.F64[i]);
-            tmp->n++;
         }
         break;
@@ -959,5 +926,4 @@
             tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F32[i],
                                                   y->data.F32[i], z->data.F32[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F32)
@@ -966,5 +932,4 @@
             tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F32[i],
                                                   y->data.F32[i], z->data.F64[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F64)
@@ -973,5 +938,4 @@
             tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F32[i],
                                                   y->data.F64[i], z->data.F32[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F64)
@@ -980,5 +944,4 @@
             tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F32[i],
                                                   y->data.F64[i], z->data.F64[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F32)
@@ -987,5 +950,4 @@
             tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F64[i],
                                                   y->data.F32[i], z->data.F32[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F32)
@@ -994,5 +956,4 @@
             tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F64[i],
                                                   y->data.F32[i], z->data.F64[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F64)
@@ -1001,5 +962,4 @@
             tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F64[i],
                                                   y->data.F64[i], z->data.F32[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F64)
@@ -1008,5 +968,4 @@
             tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F64[i],
                                                   y->data.F64[i], z->data.F64[i]);
-            tmp->n++;
         }
     }
@@ -1079,5 +1038,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i],
                                                   y->data.F32[i], z->data.F32[i], t->data.F32[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F32)
@@ -1086,5 +1044,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i],
                                                   y->data.F32[i], z->data.F32[i], t->data.F64[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F32)
@@ -1093,5 +1050,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i],
                                                   y->data.F32[i], z->data.F64[i], t->data.F32[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F32)
@@ -1100,5 +1056,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i],
                                                   y->data.F32[i], z->data.F64[i], t->data.F64[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F64)
@@ -1107,5 +1062,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i],
                                                   y->data.F64[i], z->data.F32[i], t->data.F32[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F64)
@@ -1114,5 +1068,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i],
                                                   y->data.F64[i], z->data.F32[i], t->data.F64[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F64)
@@ -1121,5 +1074,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i],
                                                   y->data.F64[i], z->data.F64[i], t->data.F32[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F64)
@@ -1128,5 +1080,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i],
                                                   y->data.F64[i], z->data.F64[i], t->data.F64[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F32)
@@ -1135,5 +1086,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i],
                                                   y->data.F32[i], z->data.F32[i], t->data.F32[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F32)
@@ -1142,5 +1092,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i],
                                                   y->data.F32[i], z->data.F32[i], t->data.F64[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F32)
@@ -1149,5 +1098,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i],
                                                   y->data.F32[i], z->data.F64[i], t->data.F32[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F32)
@@ -1156,5 +1104,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i],
                                                   y->data.F32[i], z->data.F64[i], t->data.F64[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F64)
@@ -1163,5 +1110,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i],
                                                   y->data.F64[i], z->data.F32[i], t->data.F32[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F64)
@@ -1170,5 +1116,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i],
                                                   y->data.F64[i], z->data.F32[i], t->data.F64[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F64)
@@ -1177,5 +1122,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i],
                                                   y->data.F64[i], z->data.F64[i], t->data.F32[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F64)
@@ -1185,5 +1129,4 @@
                                                   y->data.F64[i], z->data.F64[i],
                                                   t->data.F64[i]);
-            tmp->n++;
         }
     }
Index: /trunk/psLib/src/math/psPolynomial.h
===================================================================
--- /trunk/psLib/src/math/psPolynomial.h	(revision 9729)
+++ /trunk/psLib/src/math/psPolynomial.h	(revision 9730)
@@ -11,6 +11,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.63 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-06-30 02:20:06 $
+ *  @version $Revision: 1.64 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:52:56 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -45,16 +45,4 @@
     float sigma,                       ///< Standard deviation for the Gaussian
     bool normal                        ///< Indicates whether result should be normalized
-);
-
-/** Produce a vector of random numbers from a Gaussian distribution with
- *  the specified mean and sigma
- *
- *  @return psVector*    vector of random numbers
- *
- */
-psVector* p_psGaussianDev(
-    psF32 mean,                        ///< The mean of the Gaussian
-    psF32 sigma,                       ///< The sigma of the Gaussian
-    unsigned int Npts                  ///< The size of the vector
 );
 
Index: /trunk/psLib/src/math/psSparse.c
===================================================================
--- /trunk/psLib/src/math/psSparse.c	(revision 9729)
+++ /trunk/psLib/src/math/psSparse.c	(revision 9730)
@@ -35,17 +35,12 @@
     psMemSetDeallocator(sparse, (psFreeFunc)sparseFree);
 
-    sparse->Aij = psVectorAlloc(Nelem, PS_DATA_F32);
-    sparse->Si  = psVectorAlloc(Nelem, PS_DATA_S32);
-    sparse->Sj  = psVectorAlloc(Nelem, PS_DATA_S32);
-
-    sparse->Aij->n = 0;
-    sparse->Si->n  = 0;
-    sparse->Sj->n  = 0;
+    sparse->Aij = psVectorAllocEmpty(Nelem, PS_DATA_F32);
+    sparse->Si  = psVectorAllocEmpty(Nelem, PS_DATA_S32);
+    sparse->Sj  = psVectorAllocEmpty(Nelem, PS_DATA_S32);
+
     sparse->Nelem = 0;
 
     sparse->Bfj = psVectorAlloc(Nrows, PS_DATA_F32);
     sparse->Qii = psVectorAlloc(Nrows, PS_DATA_F32);
-    sparse->Bfj->n = Nrows;
-    sparse->Qii->n = Nrows;
 
     sparse->Nrows = Nrows;
@@ -157,5 +152,4 @@
     // temporary storage for intermediate results
     psVector *dQ = psVectorAlloc(output->n, PS_DATA_F32);
-    dQ->n = output->n;
 
     for (int j = 0; j < Niter; j++) {
@@ -197,5 +191,4 @@
     psVector *tSi  = psVectorAlloc(Nelem, PS_DATA_S32);
     psVector *tSj  = psVectorAlloc(Nelem, PS_DATA_S32);
-    tAij->n = tSi->n = tSj->n = Nelem;
 
     for (int i = 0; i < Nelem; i++) {
Index: /trunk/psLib/src/math/psSpline.c
===================================================================
--- /trunk/psLib/src/math/psSpline.c	(revision 9729)
+++ /trunk/psLib/src/math/psSpline.c	(revision 9730)
@@ -6,6 +6,6 @@
 *  This file contains the routines that allocate, free, and evaluate splines.
 *
-*  @version $Revision: 1.155 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-10-13 22:04:58 $
+*  @version $Revision: 1.156 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-10-24 22:52:56 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -239,10 +239,8 @@
             for (psS32 i = 0 ; i < x->n ; i++) {
                 spline->knots->data.F32[i] = x->data.F32[i];
-                spline->knots->n++;
             }
         } else if (x->type.type == PS_TYPE_F64) {
             for (psS32 i = 0 ; i < x->n ; i++) {
                 spline->knots->data.F32[i] = (psF32) x->data.F64[i];
-                spline->knots->n++;
             }
         }
@@ -250,5 +248,4 @@
         for (psS32 i = 0 ; i < y->n ; i++) {
             spline->knots->data.F32[i] = (psF32) i;
-            spline->knots->n++;
         }
     }
@@ -415,10 +412,8 @@
         for (psS32 i=0;i<x->n;i++) {
             tmpVector->data.F32[i] = psSpline1DEval(spline, x->data.F32[i]);
-            tmpVector->n++;
         }
     } else if (x->type.type == PS_TYPE_F64) {
         for (psS32 i=0;i<x->n;i++) {
             tmpVector->data.F32[i] = psSpline1DEval(spline, (psF32) x->data.F64[i]);
-            tmpVector->n++;
         }
     }
Index: /trunk/psLib/src/math/psStats.c
===================================================================
--- /trunk/psLib/src/math/psStats.c	(revision 9729)
+++ /trunk/psLib/src/math/psStats.c	(revision 9730)
@@ -16,6 +16,6 @@
  * use ->min and ->max (PS_STAT_USE_RANGE)
  *
- *  @version $Revision: 1.187 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-13 22:04:58 $
+ *  @version $Revision: 1.188 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:52:56 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -388,5 +388,5 @@
 
     // Allocate temporary vectors for the data.
-    psVector* vector = psVectorAlloc(myVector->n, PS_TYPE_F32); // Vector containing the unmasked values
+    psVector* vector = psVectorAllocEmpty(myVector->n, PS_TYPE_F32); // Vector containing the unmasked values
     long count = 0;                     // Number of valid entries
 
@@ -486,5 +486,4 @@
     long numBins = histogram->nums->n;  // Number of histogram bins
     psVector *smooth = psVectorAlloc(numBins, PS_TYPE_F32); // Smoothed version of histogram bins
-    smooth->n = smooth->nalloc;
     const psVector *bounds = histogram->bounds; // The bounds for the histogram bins
 
@@ -723,5 +722,4 @@
     // We copy the mask vector, to preserve the original
     psVector *tmpMask = psVectorAlloc(myVector->n, PS_TYPE_U8);
-    tmpMask->n = tmpMask->nalloc;
     psVectorInit(tmpMask, 0);
     if (maskVector) {
@@ -901,6 +899,4 @@
     psVector *x = psVectorAlloc(3, PS_TYPE_F64);
     psVector *y = psVectorAlloc(3, PS_TYPE_F64);
-    x->n = 3;
-    y->n = 3;
     psF32 tmpFloat = 0.0f;
 
@@ -1066,5 +1062,4 @@
 
     psVector *mask = psVectorAlloc(myVector->n, PS_TYPE_MASK); // The actual mask we will use
-    mask->n = myVector->n;
     psVectorInit(mask, 0);
     if (maskVector) {
@@ -1487,10 +1482,7 @@
         psVector *y = psVectorAlloc((1 + (binMax - binMin)), PS_TYPE_F32); // Vector of coordinates
         psArray *x = psArrayAlloc((1 + (binMax - binMin))); // Array of ordinates
-        y->n = y->nalloc;
-        x->n = x->nalloc;
         for (long i = binMin, j = 0; i <= binMax ; i++, j++) {
             y->data.F32[j] = smoothed->data.F32[i];
             psVector *ordinate = psVectorAlloc(1, PS_TYPE_F32); // The ordinate value
-            ordinate->n = 1;
             ordinate->data.F32[0] = PS_BIN_MIDPOINT(histogram, i);
             x->data[j] = ordinate;
@@ -1521,5 +1513,4 @@
         psMinimization *minimizer = psMinimizationAlloc(100, 0.01); // The minimizer information
         psVector *params = psVectorAlloc(2, PS_TYPE_F32); // Parameters for the Gaussian
-        params->n = params->nalloc;
         // Initial guess for the mean (index 0) and standard dev (index 1).
         params->data.F32[0] = stats->robustMedian;
@@ -1654,5 +1645,4 @@
     psVector* newBounds = psVectorAlloc(n + 1, PS_TYPE_F32);
     newHist->bounds = newBounds;
-    newBounds->n = newHist->bounds->nalloc;
 
     // Calculate the bounds for each bin.
@@ -1666,8 +1656,5 @@
     // Allocate the bins, and initialize them to zero.
     newHist->nums = psVectorAlloc(n, PS_TYPE_F32);
-    for (long i = 0; i < newHist->nums->nalloc; i++) {
-        newHist->nums->data.F32[i] = 0.0;
-        newHist->nums->n++;
-    }
+    psVectorInit(newHist->nums, 0.0);
 
     // Initialize the other members.
@@ -1699,18 +1686,11 @@
     psHistogram *newHist = (psHistogram* ) psAlloc(sizeof(psHistogram)); // The new histogram structure
     psMemSetDeallocator(newHist, (psFreeFunc) histogramFree);
-    psVector* newBounds = psVectorAlloc(bounds->n, PS_TYPE_F32);
+    psVector* newBounds = psVectorCopy(NULL, bounds, PS_TYPE_F32);
     newHist->bounds = newBounds;
-    newBounds->n = newHist->bounds->nalloc;
-    for (long i = 0; i < bounds->n; i++) {
-        newBounds->data.F32[i] = bounds->data.F32[i];
-    }
 
     // Allocate the bins, and initialize them to zero.  If there are N bounds,
     // then there are N-1 bins.
     newHist->nums = psVectorAlloc((bounds->n) - 1, PS_TYPE_F32);
-    for (long i = 0; i < newHist->nums->nalloc; i++) {
-        newHist->nums->data.F32[i] = 0.0;
-        newHist->nums->n++;
-    }
+    psVectorInit(newHist->nums, 0.0);
 
     // Initialize the other members.
Index: /trunk/psLib/src/mathtypes/psVector.c
===================================================================
--- /trunk/psLib/src/mathtypes/psVector.c	(revision 9729)
+++ /trunk/psLib/src/mathtypes/psVector.c	(revision 9730)
@@ -9,6 +9,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.86 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-10-14 00:12:39 $
+*  @version $Revision: 1.87 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-10-24 22:52:56 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -68,11 +68,10 @@
 
 
-psVector* psVectorAlloc(long nalloc,
-                        psElemType type)
-{
-    psVector* psVec = NULL;
-    psS32 elementSize = 0;
-
-    elementSize = PSELEMTYPE_SIZEOF(type);
+// Allocate a psVector; does not set vector->n (left to the caller)
+static psVector *vectorAlloc(long nalloc, // Number of elements to allocate
+                             psElemType type // Type of elements
+                            )
+{
+    int elementSize = PSELEMTYPE_SIZEOF(type); // Size, in bytes, of element
     if (elementSize < 1) {
         psError(PS_ERR_BAD_PARAMETER_TYPE, true,
@@ -81,19 +80,38 @@
     }
 
-
     // Create vector struct
-    psVec = (psVector* ) psAlloc(sizeof(psVector));
-    psMemSetDeallocator(psVec, (psFreeFunc) vectorFree);
-
-    psVec->type.dimen = PS_DIMEN_VECTOR;
-    psVec->type.type = type;
-    P_PSVECTOR_SET_NALLOC(psVec,nalloc);
-    //    psVec->n = nalloc;
-    psVec->n = 0;
+    psVector *vector = (psVector*) psAlloc(sizeof(psVector));
+    psMemSetDeallocator(vector, (psFreeFunc) vectorFree);
+
+    vector->type.dimen = PS_DIMEN_VECTOR;
+    vector->type.type = type;
+    P_PSVECTOR_SET_NALLOC(vector, nalloc);
 
     // Create vector data array
-    psVec->data.U8 = psAlloc(nalloc * elementSize);
-
-    return psVec;
+    vector->data.U8 = psAlloc(nalloc * elementSize);
+
+    return vector;
+}
+
+psVector* psVectorAlloc(long nalloc,
+                        psElemType type)
+{
+    psVector *vector = vectorAlloc(nalloc, type);
+    if (!vector) {
+        return NULL;
+    }
+    vector->n = nalloc;
+    return vector;
+}
+
+psVector* psVectorAllocEmpty(long nalloc,
+                             psElemType type)
+{
+    psVector *vector = vectorAlloc(nalloc, type);
+    if (!vector) {
+        return NULL;
+    }
+    vector->n = 0;
+    return vector;
 }
 
Index: /trunk/psLib/src/mathtypes/psVector.h
===================================================================
--- /trunk/psLib/src/mathtypes/psVector.h	(revision 9729)
+++ /trunk/psLib/src/mathtypes/psVector.h	(revision 9730)
@@ -11,6 +11,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.58 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-14 00:07:13 $
+ *  @version $Revision: 1.59 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:52:56 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -74,5 +74,5 @@
         ;
 
-/** Allocate a vector.
+/** Allocate a vector, with length set to number allocated
  *
  *  Uses psLib memory allocation functions to create a vector collection of
@@ -82,4 +82,16 @@
  */
 psVector* psVectorAlloc(
+    long nalloc,                       ///< Total number of elements to make available.
+    psElemType type                    ///< Type of data to be held by vector.
+);
+
+/** Allocate a vector, with length set to zero
+ *
+ *  Uses psLib memory allocation functions to create a vector collection of
+ *  data as defined by the psType type.
+ *
+ * @return psVector*    Pointer to psVector.
+ */
+psVector* psVectorAllocEmpty(
     long nalloc,                       ///< Total number of elements to make available.
     psElemType type                    ///< Type of data to be held by vector.
Index: /trunk/psLib/src/sys/psError.c
===================================================================
--- /trunk/psLib/src/sys/psError.c	(revision 9729)
+++ /trunk/psLib/src/sys/psError.c	(revision 9730)
@@ -11,6 +11,6 @@
  *  @author Eric Van Alst, MHPCC
  *
- *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-18 15:26:33 $
+ *  @version $Revision: 1.41 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:52:56 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -84,5 +84,5 @@
     if ((errorStack = pthread_getspecific(errorStack_key)) == NULL) {
         // allocate the error stack
-        errorStack = psArrayAlloc(MAX_ERROR_STACK_SIZE);
+        errorStack = psArrayAllocEmpty(MAX_ERROR_STACK_SIZE);
         p_psMemSetPersistent(errorStack, true);
         p_psMemSetPersistent(errorStack->data, true);
Index: /trunk/psLib/src/types/psArray.c
===================================================================
--- /trunk/psLib/src/types/psArray.c	(revision 9729)
+++ /trunk/psLib/src/types/psArray.c	(revision 9730)
@@ -9,6 +9,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.56 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-13 22:24:29 $
+ *  @version $Revision: 1.57 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:52:56 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -49,4 +49,24 @@
 }
 
+// Allocate an array, deliberately leave size unset.
+static psArray *arrayAlloc(long nalloc)
+{
+    if (nalloc < 0) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                "Can't allocate a psArray of negative size.");
+        return NULL;
+    }
+
+    // Create vector struct
+    psArray *array = (psArray*)psAlloc(sizeof(psArray));
+    psMemSetDeallocator(array, (psFreeFunc)arrayFree);
+
+    P_PSARRAY_SET_NALLOC(array, nalloc);
+    // Create vector data array
+    array->data = psAlloc(nalloc * sizeof(psPtr));
+    memset(array->data, 0, sizeof(void*) * nalloc);  //set the initial values of data to NULL
+
+    return array;
+}
 
 /*****************************************************************************
@@ -55,22 +75,20 @@
 psArray* psArrayAlloc(long nalloc)
 {
-    if (nalloc < 0) {
-        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
-                "Can't allocate a psArray of negative size.");
-        return NULL;
-    }
-    psArray* psArr = NULL;
-
-    // Create vector struct
-    psArr = (psArray* ) psAlloc(sizeof(psArray));
-    psMemSetDeallocator(psArr, (psFreeFunc) arrayFree);
-
-    P_PSARRAY_SET_NALLOC(psArr,nalloc);
-    psArr->n = 0;  //set the initial number of elements in use to 0
-    // Create vector data array
-    psArr->data = psAlloc(nalloc * sizeof(psPtr));
-    memset(psArr->data, 0, sizeof(void*) * nalloc);  //set the initial values of data to NULL
-
-    return psArr;
+    psArray *array = arrayAlloc(nalloc);
+    if (!array) {
+        return NULL;
+    }
+    array->n = nalloc;
+    return array;
+}
+
+psArray* psArrayAllocEmpty(long nalloc)
+{
+    psArray *array = arrayAlloc(nalloc);
+    if (!array) {
+        return NULL;
+    }
+    array->n = 0;
+    return array;
 }
 
Index: /trunk/psLib/src/types/psArray.h
===================================================================
--- /trunk/psLib/src/types/psArray.h	(revision 9729)
+++ /trunk/psLib/src/types/psArray.h	(revision 9730)
@@ -11,6 +11,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-13 22:24:29 $
+ *  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:52:56 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -60,5 +60,5 @@
 
 
-/** Allocate an array.
+/** Allocate an array, set the length to the number of allocated elements
  *
  * Uses psLib memory allocation functions to create an array collection of
@@ -69,4 +69,16 @@
  */
 psArray* psArrayAlloc(
+    long nalloc                        ///< Total number of elements to make available.
+);
+
+/** Allocate an array, set the length to zero.
+ *
+ * Uses psLib memory allocation functions to create an array collection of
+ * data
+ *
+ * @return psArray* : Pointer to psArray.
+ *
+ */
+psArray* psArrayAllocEmpty(
     long nalloc                        ///< Total number of elements to make available.
 );
Index: /trunk/psLib/src/types/psHash.c
===================================================================
--- /trunk/psLib/src/types/psHash.c	(revision 9729)
+++ /trunk/psLib/src/types/psHash.c	(revision 9730)
@@ -12,6 +12,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-10-13 21:13:48 $
+*  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-10-24 22:52:56 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -433,5 +433,4 @@
 
     psArray* result = psArrayAlloc(nElements);
-    result->n = nElements;
 
     // now fill in the array with the hash hash's data
Index: /trunk/psLib/src/types/psList.c
===================================================================
--- /trunk/psLib/src/types/psList.c	(revision 9729)
+++ /trunk/psLib/src/types/psList.c	(revision 9730)
@@ -6,6 +6,6 @@
  *  @author Robert Daniel DeSonia, MHPCC
  *
- *  @version $Revision: 1.55 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-13 21:13:48 $
+ *  @version $Revision: 1.56 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:52:56 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -25,4 +25,6 @@
 #define ITER_INIT_HEAD ((psPtr )1)         // next iteration should return head
 #define ITER_INIT_TAIL ((psPtr )2)         // next iteration should return tail
+
+#define INITIAL_NUM_ITERATORS 16        // Initial number of iterators to create
 
 // private functions.
@@ -125,6 +127,5 @@
     list->n = 0;
     list->head = list->tail = NULL;
-    list->iterators = psArrayAlloc(16);
-    list->iterators->n = 0;
+    list->iterators = psArrayAllocEmpty(INITIAL_NUM_ITERATORS);
 
     // create a default iterator
@@ -564,24 +565,10 @@
 psArray* psListToArray(const psList* list)
 {
-    psListElem* ptr;
-    psU32 n;
-    psArray* arr;
-
-    if (list == NULL) {
-        return NULL;
-    }
-
-    //XXX: Following is unnecessary as a list->n = 0 should do ArrayAlloc(0) I believe.
-    /*    if (list->n > 0) {
-            arr = psArrayAlloc(list->n);
-        } else {
-            arr = psArrayAlloc(1);
-        }
-    */
-    arr = psArrayAlloc(list->n);
-    arr->n = list->n;
-
-    ptr = list->head;
-    n = list->n;
+    PS_ASSERT_PTR_NON_NULL(list, NULL);
+
+    long n = list->n;
+    psArray *arr = psArrayAlloc(n);
+
+    psListElem *ptr = list->head;
     for (psS32 i = 0; i < n; i++) {
         arr->data[i] = psMemIncrRefCounter(ptr->data);
Index: /trunk/psLib/src/types/psLookupTable.c
===================================================================
--- /trunk/psLib/src/types/psLookupTable.c	(revision 9729)
+++ /trunk/psLib/src/types/psLookupTable.c	(revision 9730)
@@ -7,6 +7,6 @@
 *  @author Ross Harman, MHPCC
 *
-*  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-10-22 00:51:05 $
+*  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-10-24 22:52:56 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii
@@ -36,5 +36,5 @@
 #define MAX_STRING_LENGTH   256
 #define ARRAY_STRIDE        16
-
+#define INITIAL_NUM         10          // Initial number of elements
 /******************************************************************************/
 /*  TYPE DEFINITIONS                                                          */
@@ -449,6 +449,5 @@
 
     // Create output array and set array elements to zero
-    outputArray = psArrayAlloc(10);
-    outputArray->n = 0;
+    outputArray = psArrayAllocEmpty(INITIAL_NUM);
 
     // Parse the format string to determine how many vectors
@@ -629,5 +628,4 @@
     // Check if array is sorted on the index column
     psVector* sortedIndex = psVectorAlloc(numRows,PS_TYPE_U32);
-    sortedIndex->n = numRows;
     sortedIndex = psVectorSortIndex(sortedIndex,indexColumnVector);
     for(psS32 i = 0; i < numRows; i++ ) {
@@ -645,6 +643,4 @@
             psS32 type = ((psVector*)(vectors->data[j]))->type.type;
             newValueArray->data[j] = psVectorAlloc(numRows,type);
-            ((psVector*)(newValueArray->data[j]))->n = numRows;
-            newValueArray->n++;
         }
 
Index: /trunk/psLib/src/types/psMetadataConfig.c
===================================================================
--- /trunk/psLib/src/types/psMetadataConfig.c	(revision 9729)
+++ /trunk/psLib/src/types/psMetadataConfig.c	(revision 9730)
@@ -10,6 +10,6 @@
 *  @author Eric Van Alst, MHPCC
 *
-*  @version $Revision: 1.95 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-10-24 01:15:47 $
+*  @version $Revision: 1.96 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-10-24 22:52:56 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -47,4 +47,5 @@
 /** Maximum size of a string */
 #define MAX_STRING_LENGTH 1024
+#define INITIAL_LENGTH 10               // Initial length for arrays
 
 /******************************************************************************/
@@ -73,9 +74,24 @@
 static psMetadata* setMetadataItem(psMetadata* template, char* linePtr)
 ;
-static void parseLevelInfoFree(p_psParseLevelInfo* info);
-static psBool parseLine(psS32* level,   psArray* levelArray, char*  linePtr, psS32 lineCount, psBool overwrite);
-static psBool parseMetadataItem(char* keyName, psS32* level, psArray* levelArray, char* linePtr, psS32 lineCount, psMetadataFlags flags);
+static psBool parseLine(psS32* level,   psArray* levelArray, char*  linePtr,
+                        psS32 lineCount, psBool overwrite);
+static psBool parseMetadataItem(char* keyName, psS32* level, psArray* levelArray,
+                                char* linePtr, psS32 lineCount, psMetadataFlags flags);
 static psString formatMetadataItem(psMetadataItem *item);
 static psArray *p_psMetadataKeyArray(psMetadata *md);
+
+
+// A metadata data structure used in parsing arrays.
+// Contains array information and the metadata storage location.
+typedef struct
+{
+    psArray*    nonUniqueKeyArray;     ///< non-unique key names
+    psArray*    typeArray;             ///< array of user defined types
+    psArray*    templateArray;         ///< array of user type templates
+    psMetadata* metadata;              ///< metadata container
+    char*       name;                  ///< name of key
+}
+p_psParseLevelInfo;
+
 static void parseLevelInfoFree(p_psParseLevelInfo* info)
 {
@@ -85,4 +101,19 @@
     psFree(info->name);
     psFree(info->metadata);
+}
+
+static p_psParseLevelInfo* p_psParseLevelInfoAlloc(void)
+{
+    // Allocate memory for parse level info
+    p_psParseLevelInfo *info = (p_psParseLevelInfo*)psAlloc(sizeof(p_psParseLevelInfo));
+    psMemSetDeallocator(info,(psFreeFunc)parseLevelInfoFree);
+
+    info->nonUniqueKeyArray = psArrayAllocEmpty(INITIAL_LENGTH);
+    info->typeArray = psArrayAllocEmpty(INITIAL_LENGTH);
+    info->templateArray = psArrayAllocEmpty(INITIAL_LENGTH);
+    info->metadata = NULL;
+    info->name = NULL;
+
+    return info;
 }
 
@@ -350,5 +381,5 @@
         inString = saveValue;
         end = NULL;
-        vec = psVectorAlloc(numValues, elemType);
+        vec = psVectorAllocEmpty(numValues, elemType);
 
         while(*inString!='\0') {
@@ -406,33 +437,8 @@
 }
 
+
 /*****************************************************************************/
 /* FUNCTION IMPLEMENTATION - PUBLIC                                          */
 /*****************************************************************************/
-
-p_psParseLevelInfo* p_psParseLevelInfoAlloc(void)
-{
-
-    p_psParseLevelInfo* info = NULL;
-
-    // Allocate memory for parse level info
-    info = (p_psParseLevelInfo*)psAlloc(sizeof(p_psParseLevelInfo));
-
-    // If allocation successful then initialize members
-    if(info != NULL) {
-
-        info->nonUniqueKeyArray = psArrayAlloc(10);
-
-        info->typeArray = psArrayAlloc(10);
-
-        info->templateArray = psArrayAlloc(10);
-
-        info->metadata = NULL;
-        info->name = NULL;
-
-        // Set memory deallocator
-        psMemSetDeallocator(info,(psFreeFunc)parseLevelInfoFree);
-    }
-    return info;
-}
 
 bool psMetadataItemPrint(FILE * fd,
@@ -1220,5 +1226,5 @@
 
     // Allocate array to store parse level information
-    parseLevelInfoArray = psArrayAlloc(10);
+    parseLevelInfoArray = psArrayAllocEmpty(INITIAL_LENGTH);
 
     // Set parse level info for the top level
@@ -1522,5 +1528,5 @@
     PS_ASSERT_PTR_NON_NULL(md, NULL);
 
-    psArray *keys = psArrayAlloc(psListLength(md->list));
+    psArray *keys = psArrayAllocEmpty(psListLength(md->list));
 
     // since we want to preserve the order of the keys in the metadata we can't
Index: /trunk/psLib/src/types/psMetadataConfig.h
===================================================================
--- /trunk/psLib/src/types/psMetadataConfig.h	(revision 9729)
+++ /trunk/psLib/src/types/psMetadataConfig.h	(revision 9730)
@@ -10,6 +10,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-24 01:15:47 $
+ *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:52:56 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -22,24 +22,4 @@
 /// @addtogroup Metadata
 /// @{
-
-/** A metadata data structure used in parsing arrays.
- *
- *  Contains array information and the metadata storage location.
-*/
-typedef struct
-{
-    psArray*    nonUniqueKeyArray;     ///< non-unique key names
-    psArray*    typeArray;             ///< array of user defined types
-    psArray*    templateArray;         ///< array of user type templates
-    psMetadata* metadata;              ///< metadata container
-    char*       name;                  ///< name of key
-}
-p_psParseLevelInfo;
-
-/** Allocates a p_psParseLevelInfo structure
- *
- *  @return p_psParseLevelInfo* :   new p_psParseLevelInfo struct
- */
-p_psParseLevelInfo* p_psParseLevelInfoAlloc(void);
 
 /** Print metadata item to file.
Index: /trunk/psModules/src/astrom/pmAstrometryDistortion.c
===================================================================
--- /trunk/psModules/src/astrom/pmAstrometryDistortion.c	(revision 9729)
+++ /trunk/psModules/src/astrom/pmAstrometryDistortion.c	(revision 9730)
@@ -7,6 +7,6 @@
 *  @author EAM, IfA
 *
-*  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-09-15 09:49:01 $
+*  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-10-24 22:55:04 $
 *
 *  Copyright 2006 Institute for Astronomy, University of Hawaii
@@ -54,5 +54,5 @@
 
     if (grads == NULL) {
-        grads = psArrayAlloc (100);
+        grads = psArrayAllocEmpty (100);
     }
 
@@ -76,8 +76,8 @@
             int Ymax = Ymin + DY;
 
-            psVector *L  = psVectorAlloc (100, PS_TYPE_F32);
-            psVector *M  = psVectorAlloc (100, PS_TYPE_F32);
-            psVector *dP = psVectorAlloc (100, PS_TYPE_F32);
-            psVector *dQ = psVectorAlloc (100, PS_TYPE_F32);
+            psVector *L  = psVectorAllocEmpty (100, PS_TYPE_F32);
+            psVector *M  = psVectorAllocEmpty (100, PS_TYPE_F32);
+            psVector *dP = psVectorAllocEmpty (100, PS_TYPE_F32);
+            psVector *dQ = psVectorAllocEmpty (100, PS_TYPE_F32);
             int Npts = 0;
 
@@ -121,5 +121,4 @@
             psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV);
             psVector *mask = psVectorAlloc (Npts, PS_TYPE_MASK);
-            mask->n = Npts;
             psVectorInit (mask, 0);
 
@@ -175,10 +174,7 @@
         M->data.F32[i] = grad->FP.y;
     }
-    dPdL->n = dQdL->n = dPdM->n = dQdM->n = grads->n;
-    L->n = M->n = grads->n;
 
     psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV);
     psVector *mask = psVectorAlloc (grads->n, PS_TYPE_MASK);
-    mask->n = grads->n;
     psVectorInit (mask, 0);
 
Index: /trunk/psModules/src/astrom/pmAstrometryObjects.c
===================================================================
--- /trunk/psModules/src/astrom/pmAstrometryObjects.c	(revision 9729)
+++ /trunk/psModules/src/astrom/pmAstrometryObjects.c	(revision 9730)
@@ -8,6 +8,6 @@
 *  @author EAM, IfA
 *
-*  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-10-19 02:56:40 $
+*  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-10-24 22:55:04 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -76,6 +76,5 @@
                             const double RADIUS) // matching radius
 {
-    psArray *matches = psArrayAlloc(x1->n);
-    matches->n = 0;
+    psArray *matches = psArrayAllocEmpty(x1->n);
 
     const double RADIUS_SQR = PS_SQR(RADIUS);
@@ -144,6 +143,4 @@
     /* sort both lists by X coord; st1 first */ \
     psVector *x1 = psVectorAlloc(st1->n, PS_TYPE_F64); \
-    \
-    x1->n = x1->nalloc; \
     for (int i = 0; i < st1->n; i++) { \
         x1->data.F64[i] = ((pmAstromObj *)st1->data[i])->MEMBER->x; \
@@ -153,5 +150,4 @@
     \
     psVector *y1 = psVectorAlloc(st1->n, PS_TYPE_F64); \
-    y1->n = y1->nalloc; \
     for (int i = 0; i < st1->n; i++) { \
         x1->data.F64[i] = ((pmAstromObj *)st1->data[sorted1->data.S32[i]])->MEMBER->x; \
@@ -161,5 +157,4 @@
     /* now st2 */ \
     psVector *x2 = psVectorAlloc(st2->n, PS_TYPE_F64); \
-    x2->n = x2->nalloc; \
     for (int i = 0; i < st2->n; i++) { \
         x2->data.F64[i] = ((pmAstromObj *)st2->data[i])->MEMBER->x; \
@@ -168,5 +163,4 @@
     \
     psVector *y2 = psVectorAlloc(st2->n, PS_TYPE_F64); \
-    y2->n = y2->nalloc; \
     for (int i = 0; i < st2->n; i++) { \
         x2->data.F64[i] = ((pmAstromObj *)st2->data[sorted2->data.S32[i]])->MEMBER->x; \
@@ -236,9 +230,4 @@
     psVector *y = psVectorAlloc (match->n, PS_TYPE_F32);
     psVector *wt = psVectorAlloc (match->n, PS_TYPE_F32);
-    X->n = X->nalloc;
-    Y->n = Y->nalloc;
-    x->n = x->nalloc;
-    y->n = y->nalloc;
-    wt->n = wt->nalloc;
     // take the matched stars, first fit
     for (int i = 0; i < match->n; i++) {
@@ -259,5 +248,4 @@
     // constant errors
     psVector *mask = psVectorAlloc (match->n, PS_TYPE_U8);
-    mask->n = match->n;
     psVectorInit (mask, 0);
 
@@ -352,5 +340,4 @@
 
     psArray *new = psArrayAlloc (old->n);
-    new->n = new->nalloc;
     double cs = cos(angle);
     double sn = sin(angle);
@@ -659,5 +646,4 @@
     // sort the NP values and choose
     psVector *listNP = psVectorAlloc (nPix*nPix, PS_TYPE_U32);
-    listNP->n = nPix*nPix;
     int n = 0;
     for (int i = 0; i < nPix; i++) {
@@ -780,5 +766,4 @@
     psVector *xHist = psVectorAlloc (nBin, PS_TYPE_F32);
     psVector *yHist = psVectorAlloc (nBin, PS_TYPE_F32);
-    xHist->n = yHist->n = nBin;
     psVectorInit (xHist, 0);
     psVectorInit (yHist, 0);
Index: /trunk/psModules/src/camera/pmFPAConstruct.c
===================================================================
--- /trunk/psModules/src/camera/pmFPAConstruct.c	(revision 9729)
+++ /trunk/psModules/src/camera/pmFPAConstruct.c	(revision 9730)
@@ -61,5 +61,4 @@
     *second = psArrayAlloc(values->n);
     *third = psArrayAlloc(values->n);
-    (*first)->n = (*second)->n = (*third)->n = values->n;
     int num = 0;
     psListIterator *valuesIter = psListIteratorAlloc(values, PS_LIST_HEAD, false); // Iterator for values
Index: /trunk/psModules/src/camera/pmFPAMaskWeight.c
===================================================================
--- /trunk/psModules/src/camera/pmFPAMaskWeight.c	(revision 9729)
+++ /trunk/psModules/src/camera/pmFPAMaskWeight.c	(revision 9730)
@@ -29,5 +29,4 @@
     if (!masks) {
         masks = psArrayAlloc(images->n);
-        masks->n = images->n;
         hdu->masks = masks;
     }
@@ -56,5 +55,4 @@
     if (!weights) {
         weights = psArrayAlloc(images->n);
-        weights->n = images->n;
         hdu->weights = weights;
     }
Index: /trunk/psModules/src/camera/pmHDUGenerate.c
===================================================================
--- /trunk/psModules/src/camera/pmHDUGenerate.c	(revision 9729)
+++ /trunk/psModules/src/camera/pmHDUGenerate.c	(revision 9730)
@@ -294,5 +294,4 @@
     // Generate the HDU
     hdu->images = psArrayAlloc(numReadouts);
-    hdu->images->n = numReadouts;
     for (int i = 0; i < numReadouts; i++) {
         psImage *image = psImageAlloc(xSize, ySize, type);
Index: /trunk/psModules/src/concepts/pmConceptsWrite.c
===================================================================
--- /trunk/psModules/src/concepts/pmConceptsWrite.c	(revision 9729)
+++ /trunk/psModules/src/concepts/pmConceptsWrite.c	(revision 9730)
@@ -51,5 +51,4 @@
         }
         psVector *match = psVectorAlloc(cList->n, PS_TYPE_U8); // Array indicating which values match
-        match->n = cList->n;
         psVectorInit(match, 0);
         psListIterator *cIter = psListIteratorAlloc(cList, PS_LIST_HEAD, false); // compare iterator
Index: /trunk/psModules/src/config/pmConfig.c
===================================================================
--- /trunk/psModules/src/config/pmConfig.c	(revision 9729)
+++ /trunk/psModules/src/config/pmConfig.c	(revision 9730)
@@ -4,6 +4,6 @@
  *  @author EAM (IfA)
  *
- *  @version $Revision: 1.49 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-17 01:25:22 $
+ *  @version $Revision: 1.50 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:55:05 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -883,6 +883,5 @@
 
     // we load all input files onto a psArray, to be parsed later
-    psArray *input = psArrayAlloc (16);
-    input->n = 0;
+    psArray *input = psArrayAllocEmpty(16);
 
     // load the list of filenames the supplied file
Index: /trunk/psModules/src/detrend/pmFlatNormalize.c
===================================================================
--- /trunk/psModules/src/detrend/pmFlatNormalize.c	(revision 9729)
+++ /trunk/psModules/src/detrend/pmFlatNormalize.c	(revision 9730)
@@ -32,10 +32,8 @@
         } else {
             *expFluxesPtr = psVectorAlloc(numExps, PS_TYPE_F32);
-            (*expFluxesPtr)->n = numExps;
         }
         expFluxes = psMemIncrRefCounter(*expFluxesPtr);
     } else {
         expFluxes = psVectorAlloc(numExps, PS_TYPE_F32);
-        expFluxes->n = numExps;
     }
 
@@ -47,5 +45,4 @@
         } else {
             *chipGainsPtr = psVectorAlloc(numChips, PS_TYPE_F32);
-            (*chipGainsPtr)->n = numChips;
             psVectorInit(*chipGainsPtr, 1.0);
         }
@@ -53,5 +50,4 @@
     } else {
         chipGains = psVectorAlloc(numChips, PS_TYPE_F32);
-        chipGains->n = numChips;
         psVectorInit(chipGains, 1.0);
     }
@@ -62,8 +58,6 @@
     psImageInit(fluxMask, 0);
     psVector *gainMask = psVectorAlloc(numChips, PS_TYPE_U8); // Mask for bad gains
-    gainMask->n = numChips;
     psVectorInit(gainMask, 0);
     psVector *expMask = psVectorAlloc(numExps, PS_TYPE_U8); // Mask for bad exposures
-    expMask->n = numExps;
     psVectorInit(expMask, 0);
     for (int i = 0; i < numChips; i++) {
Index: /trunk/psModules/src/detrend/pmFringeStats.c
===================================================================
--- /trunk/psModules/src/detrend/pmFringeStats.c	(revision 9729)
+++ /trunk/psModules/src/detrend/pmFringeStats.c	(revision 9730)
@@ -133,5 +133,4 @@
 
     psArray *table = psArrayAlloc(numRows); // The table
-    table->n = numRows;
     // Translate the vectors into the required format for psFitsWriteTable()
     for (long i = 0; i < numRows; i++) {
@@ -205,5 +204,4 @@
     psVector *y = psVectorAlloc(numRows, PS_TYPE_F32); // y position
     psVector *mask = psVectorAlloc(numRows, PS_TYPE_U8); // mask
-    x->n = y->n = mask->n = numRows;
     regions->x = x;
     regions->y = y;
@@ -253,5 +251,4 @@
     stats->f = psVectorAlloc(numRegions, PS_TYPE_F32);
     stats->df = psVectorAlloc(numRegions, PS_TYPE_F32);
-    stats->f->n = stats->df->n = numRegions;
 
     return stats;
@@ -365,5 +362,4 @@
     // Vectors: f, df
     psArray *table = psArrayAlloc(numRows); // The table
-    table->n = numRows;
     // Translate the vectors into the required format for psFitsWriteTable()
     for (long i = 0; i < numRows; i++) {
@@ -527,6 +523,4 @@
     scale->coeff = psVectorAlloc(nFringeFrames + 1, PS_TYPE_F32);
     scale->coeffErr = psVectorAlloc(nFringeFrames + 1, PS_TYPE_F32);
-    scale->coeff->n = nFringeFrames + 1;
-    scale->coeff->n = nFringeFrames + 1;
 
     return scale;
@@ -551,5 +545,4 @@
     psImage *A = psImageAlloc(numCoeffs, numCoeffs, PS_TYPE_F64); // The least-squares matrix
     psVector *B = psVectorAlloc(numCoeffs, PS_TYPE_F64); // The least-squares vector
-    B->n = numCoeffs;
 
     // Generate the least-squares matrix and vector
@@ -718,5 +711,4 @@
     if (!regions->mask) {
         regions->mask = psVectorAlloc(numRegions, PS_TYPE_U8);
-        regions->mask->n = numRegions;
         psVectorInit(regions->mask, 0);
     }
@@ -725,5 +717,4 @@
     unsigned int numClipped = 0;        // Total number clipped
     psVector *diff = psVectorAlloc(numRegions, PS_TYPE_F32); // The differences between obs. and pred.
-    diff->n = numRegions;
 
     pmFringeScale *scale = pmFringeScaleAlloc(fringes->n); // The fringe scales
Index: /trunk/psModules/src/detrend/pmShutterCorrection.c
===================================================================
--- /trunk/psModules/src/detrend/pmShutterCorrection.c	(revision 9729)
+++ /trunk/psModules/src/detrend/pmShutterCorrection.c	(revision 9730)
@@ -104,5 +104,4 @@
     psVector *tmpX = psVectorAlloc(2, PS_TYPE_F32);
     psVector *tmpY = psVectorAlloc(2, PS_TYPE_F32);
-    tmpX->n = tmpY->n = 2;
 
     long index;
@@ -210,5 +209,4 @@
     psVector *x = psVectorAlloc(exptime->n, PS_TYPE_F32);
     psVector *y = psVectorAlloc(exptime->n, PS_TYPE_F32);
-    x->n = y->n = exptime->n;
 
     for (long i = 0; i < exptime->n; i++) {
@@ -301,5 +299,4 @@
     params->data.F32[1] = guess->offset;
     params->data.F32[2] = guess->offref;
-    params->n = 3;
 
     // XXX for the moment, don't set any constraints
@@ -317,9 +314,7 @@
     // construct the coordinate and value entries (y is counts)
     psArray *x = psArrayAlloc(exptime->n); // Coordinates
-    x->n = exptime->n;
 
     for (long i = 0; i < exptime->n; i++) {
         psVector *coord = psVectorAlloc(1, PS_TYPE_F32);
-        coord->n = 1;
         coord->data.F32[0] = exptime->data.F32[i];
         x->data[i] = coord;
@@ -371,8 +366,6 @@
     psRegion refRegion;                 // Reference region
     psVector *refs = psVectorAlloc(num, PS_TYPE_F32); // Reference measurements
-    refs->n = num;
     psVectorInit(refs, 0);
     psArray *regions = psArrayAlloc(MEASURE_SAMPLES); // Array of sample regions, made on each image
-    regions->n = MEASURE_SAMPLES;
     psImage *samplesMean = psImageAlloc(num, MEASURE_SAMPLES, PS_TYPE_F32); // Measurements for each file
     psImage *samplesStdev = psImageAlloc(num, MEASURE_SAMPLES, PS_TYPE_F32); // Errors for each file
@@ -505,5 +498,4 @@
     psImage *pattern = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Illumination pattern
     psVector *mask = psVectorAlloc(num, PS_TYPE_U8); // Mask for each image
-    mask->n = num;
     psVectorInit(mask, 0);
     psTrace("psModules.detrend", 2, "Performing linear fit on individual pixels...\n");
Index: /trunk/psModules/src/detrend/pmSubtractBias.c
===================================================================
--- /trunk/psModules/src/detrend/pmSubtractBias.c	(revision 9729)
+++ /trunk/psModules/src/detrend/pmSubtractBias.c	(revision 9730)
@@ -129,5 +129,4 @@
     psVector *ordinate = psVectorAlloc(pixels->n, PS_TYPE_F32); // Ordinate
     psVector *mask = psVectorAlloc(pixels->n, PS_TYPE_U8); // Mask for fitting
-    reduced->n = ordinate->n = mask->n = pixels->n;
 
     for (int i = 0; i < pixels->n; i++) {
@@ -268,5 +267,4 @@
                 // The read direction is rows
                 psArray *pixels = psArrayAlloc(image->numRows); // Array of vectors containing pixels
-                pixels->n = image->numRows;
                 for (int i = 0; i < pixels->n; i++) {
                     psVector *values = psVectorAlloc(0, PS_TYPE_F32);
@@ -312,5 +310,4 @@
                 // The read direction is columns
                 psArray *pixels = psArrayAlloc(image->numCols); // Array of vectors containing pixels
-                pixels->n = image->numCols;
                 for (int i = 0; i < pixels->n; i++) {
                     psVector *values = psVectorAlloc(0, PS_TYPE_F32);
Index: /trunk/psModules/src/detrend/pmSubtractSky.c
===================================================================
--- /trunk/psModules/src/detrend/pmSubtractSky.c	(revision 9729)
+++ /trunk/psModules/src/detrend/pmSubtractSky.c	(revision 9730)
@@ -6,6 +6,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-13 22:11:02 $
+ *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:55:05 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -345,5 +345,4 @@
     psImage *Aout = psImageAlloc(localPolyTerms, localPolyTerms, PS_TYPE_F64);
     psVector *B = psVectorAlloc(localPolyTerms, PS_TYPE_F64);
-    B->n = B->nalloc;
     psVector *outPerm = NULL;
 
@@ -412,5 +411,4 @@
     PS_ASSERT_IMAGE_NON_EMPTY(Aout, NULL);
     psVector *C = psVectorAlloc(localPolyTerms, PS_TYPE_F64);
-    C->n = C->nalloc;
     psMatrixLUSolve(C, Aout, B, outPerm);
 
Index: /trunk/psModules/src/imcombine/pmImageCombine.c
===================================================================
--- /trunk/psModules/src/imcombine/pmImageCombine.c	(revision 9729)
+++ /trunk/psModules/src/imcombine/pmImageCombine.c	(revision 9730)
@@ -8,6 +8,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-09-15 09:49:01 $
+ *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:55:05 $
  *
  *  XXX: pmRejectPixels() has a known bug with the pmImageTransform() call.
@@ -122,5 +122,4 @@
     if (*questionablePixels == NULL) {
         *questionablePixels = psArrayAlloc(numImages);
-        (*questionablePixels)->n = numImages;
     } else if ((*questionablePixels)->n != numImages) {
         *questionablePixels = psArrayRealloc(*questionablePixels, numImages);
@@ -137,5 +136,4 @@
     psVector *qpPtr = psVectorAlloc(numImages, PS_TYPE_S32);
     psVectorInit(qpPtr, 0);
-    qpPtr->n = numImages;
     //
     // Allocate the necessary psVectors for the call to psVectorStats().
@@ -144,10 +142,8 @@
     //
     psVector *pixelData = psVectorAlloc(numImages, PS_TYPE_F32);
-    pixelData->n = pixelData->nalloc;
     psVector *pixelMask = NULL;
     if (masks != NULL) {
         pixelMask = psVectorAlloc(numImages, PS_TYPE_U8);
         psVectorInit(pixelMask, 0);
-        pixelMask->n = numImages;
     }
 
@@ -156,5 +152,4 @@
         pixelErrors = psVectorAlloc(numImages, PS_TYPE_F32);
         psVectorInit(pixelErrors, 1.0);
-        pixelErrors->n = numImages;
     }
 
@@ -320,6 +315,4 @@
     psVector *pixels = psVectorAlloc(8, PS_TYPE_F32); // Array of pixels
     psVector *mask = psVectorAlloc(8, PS_TYPE_U8); // Corresponding mask
-    pixels->n = 8;
-    mask->n = 8;
 
     // Get limits
@@ -538,5 +531,4 @@
     //
     psArray *rejects = psArrayAlloc(numImages);
-    rejects->n = numImages;
     for (psS32 im = 0 ; im < numImages ; im++) {
         rejects->data[im] = (psPtr *) psPixelsAlloc(PS_REJECT_PIXEL_INITIAL_PIXEL_LIST_LENGTH);
@@ -550,5 +542,4 @@
     psVector *rPtr = psVectorAlloc(numImages, PS_TYPE_S32);
     psVectorInit(rPtr, 0);
-    rPtr->n = numImages;
 
     psS32 numCols = ((psImage *) images->data[0])->numCols;
Index: /trunk/psModules/src/imcombine/pmImageSubtract.c
===================================================================
--- /trunk/psModules/src/imcombine/pmImageSubtract.c	(revision 9729)
+++ /trunk/psModules/src/imcombine/pmImageSubtract.c	(revision 9730)
@@ -7,6 +7,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-09-15 09:49:01 $
+ *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:55:05 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -122,11 +122,7 @@
     tmp->u = psVectorAlloc(nBF, PS_TYPE_F32);
     tmp->v = psVectorAlloc(nBF, PS_TYPE_F32);
-    tmp->u->n = tmp->u->nalloc;
-    tmp->v->n = tmp->v->nalloc;
     tmp->sigma = NULL;
     tmp->xOrder = psVectorAlloc(nBF, PS_TYPE_F32);
-    tmp->xOrder->n = tmp->xOrder->nalloc;
     tmp->yOrder = psVectorAlloc(nBF, PS_TYPE_F32);
-    tmp->yOrder->n = tmp->yOrder->nalloc;
     tmp->subIndex = 0;
     tmp->preCalc = NULL;
@@ -223,6 +219,4 @@
     tmp->u = psVectorAlloc(nBF, PS_TYPE_F32);
     tmp->v = psVectorAlloc(nBF, PS_TYPE_F32);
-    tmp->u->n = tmp->u->nalloc;
-    tmp->v->n = tmp->v->nalloc;
     tmp->sigma = psVectorAlloc(nBF, PS_TYPE_F32);
     tmp->xOrder = psVectorAlloc(nBF, PS_TYPE_F32);
@@ -232,10 +226,4 @@
     tmp->spatialOrder = spatialOrder;
     tmp->preCalc = psArrayAlloc(nBF);
-    tmp->u->n = tmp->u->nalloc;
-    tmp->v->n = tmp->v->nalloc;
-    tmp->sigma->n = tmp->sigma->nalloc;
-    tmp->xOrder->n = tmp->xOrder->nalloc;
-    tmp->yOrder->n = tmp->yOrder->nalloc;
-    tmp->preCalc->n = tmp->preCalc->nalloc;
 
     //
@@ -367,5 +355,4 @@
     } else {
         stamps = (psArray *) psArrayAlloc(xNum * yNum);
-        stamps->n = stamps->nalloc;
         for (psS32 s = 0 ; s < (xNum * yNum) ; s++) {
             stamps->data[s] = (psPtr *) p_pmStampAlloc(PM_STAMP_REJECTED);
@@ -826,5 +813,4 @@
             if (stampVector == NULL) {
                 stampVector = psVectorAlloc(numSolveParams, PS_TYPE_F64);
-                stampVector->n = stampVector->nalloc;
                 stamp->vector = stampVector;
             } else {
@@ -1045,5 +1031,4 @@
     } else {
         solution = psVectorAlloc(size, PS_TYPE_F64);
-        solution->n = solution->nalloc;
     }
 
@@ -1057,5 +1042,4 @@
     psImage *sumMatrix = psImageAlloc(size, size, PS_TYPE_F64);
     psVector *sumVector = psVectorAlloc(size, PS_TYPE_F64);
-    sumVector->n = sumVector->nalloc;
     psVectorInit(sumVector, 0.0);
     psImageInit(sumMatrix, 0.0);
@@ -1150,5 +1134,4 @@
     } else {
         deviations = psVectorAlloc(stamps->n, PS_TYPE_F32);
-        deviations->n = deviations->nalloc;
         // XXX: Probably not necessary.
         psVectorInit(deviations, 0.0);
Index: /trunk/psModules/src/imcombine/pmReadoutCombine.c
===================================================================
--- /trunk/psModules/src/imcombine/pmReadoutCombine.c	(revision 9729)
+++ /trunk/psModules/src/imcombine/pmReadoutCombine.c	(revision 9730)
@@ -201,9 +201,7 @@
 
     psVector *pixels = psVectorAlloc(inputs->n, PS_TYPE_F32); // Stack of pixels
-    pixels->n = inputs->n;
     psF32 *pixelsData = pixels->data.F32; // Dereference pixels
 
     psVector *mask   = psVectorAlloc(inputs->n, PS_TYPE_U8); // Mask for stack
-    mask->n = inputs->n;
     psU8 *maskData = mask->data.U8;     // Dereference mask
 
@@ -212,5 +210,4 @@
     if (haveWeights) {
         weights = psVectorAlloc(inputs->n, PS_TYPE_F32); // Stack of weights
-        weights->n = inputs->n;
         weightsData = weights->data.F32;
     }
Index: /trunk/psModules/src/objects/models/pmModel_GAUSS.c
===================================================================
--- /trunk/psModules/src/objects/models/pmModel_GAUSS.c	(revision 9729)
+++ /trunk/psModules/src/objects/models/pmModel_GAUSS.c	(revision 9730)
@@ -45,7 +45,4 @@
     *params_min = psVectorAlloc (7, PS_TYPE_F32);
     *params_max = psVectorAlloc (7, PS_TYPE_F32);
-    (*beta_lim)->n = (*beta_lim)->nalloc;
-    (*params_min)->n = (*params_min)->nalloc;
-    (*params_max)->n = (*params_max)->nalloc;
 
     beta_lim[0][0].data.F32[PM_PAR_SKY] = 1000;
Index: /trunk/psModules/src/objects/models/pmModel_PGAUSS.c
===================================================================
--- /trunk/psModules/src/objects/models/pmModel_PGAUSS.c	(revision 9729)
+++ /trunk/psModules/src/objects/models/pmModel_PGAUSS.c	(revision 9730)
@@ -48,7 +48,4 @@
     *params_min = psVectorAlloc (7, PS_TYPE_F32);
     *params_max = psVectorAlloc (7, PS_TYPE_F32);
-    (*beta_lim)->n = (*beta_lim)->nalloc;
-    (*params_min)->n = (*params_min)->nalloc;
-    (*params_max)->n = (*params_max)->nalloc;
 
     beta_lim[0][0].data.F32[0] = 1000;
Index: /trunk/psModules/src/objects/models/pmModel_QGAUSS.c
===================================================================
--- /trunk/psModules/src/objects/models/pmModel_QGAUSS.c	(revision 9729)
+++ /trunk/psModules/src/objects/models/pmModel_QGAUSS.c	(revision 9730)
@@ -63,7 +63,4 @@
     *params_min = psVectorAlloc (8, PS_TYPE_F32);
     *params_max = psVectorAlloc (8, PS_TYPE_F32);
-    (*beta_lim)->n = (*beta_lim)->nalloc;
-    (*params_min)->n = (*params_min)->nalloc;
-    (*params_max)->n = (*params_max)->nalloc;
 
     beta_lim[0][0].data.F32[PM_PAR_SKY] = 1000;
Index: /trunk/psModules/src/objects/models/pmModel_SGAUSS.c
===================================================================
--- /trunk/psModules/src/objects/models/pmModel_SGAUSS.c	(revision 9729)
+++ /trunk/psModules/src/objects/models/pmModel_SGAUSS.c	(revision 9730)
@@ -67,7 +67,4 @@
     *params_min = psVectorAlloc (9, PS_TYPE_F32);
     *params_max = psVectorAlloc (9, PS_TYPE_F32);
-    (*beta_lim)->n = (*beta_lim)->nalloc;
-    (*params_min)->n = (*params_min)->nalloc;
-    (*params_max)->n = (*params_max)->nalloc;
 
     beta_lim[0][0].data.F32[0] = 1000;
Index: /trunk/psModules/src/objects/pmGrowthCurve.c
===================================================================
--- /trunk/psModules/src/objects/pmGrowthCurve.c	(revision 9729)
+++ /trunk/psModules/src/objects/pmGrowthCurve.c	(revision 9730)
@@ -5,6 +5,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-09-22 21:35:34 $
+ *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:55:05 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -40,5 +40,4 @@
     growth->radius = psVectorCreate (NULL, minRadius, maxRadius, 1.0, PS_TYPE_F32);
     growth->apMag  = psVectorAlloc (growth->radius->n, PS_TYPE_F32);
-    growth->apMag->n = growth->radius->n;
 
     // XXX may want to extend this to allow for a different refRadius;
Index: /trunk/psModules/src/objects/pmModel.c
===================================================================
--- /trunk/psModules/src/objects/pmModel.c	(revision 9729)
+++ /trunk/psModules/src/objects/pmModel.c	(revision 9730)
@@ -6,6 +6,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-14 00:53:23 $
+ *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:55:05 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -66,5 +66,4 @@
     tmp->params  = psVectorAlloc(Nparams, PS_TYPE_F32);
     tmp->dparams = psVectorAlloc(Nparams, PS_TYPE_F32);
-    tmp->params->n = tmp->dparams->n = Nparams;
 
     for (psS32 i = 0; i < tmp->params->n; i++) {
@@ -117,5 +116,4 @@
     x->data.F32[0] = (psF32) (col + image->col0);
     x->data.F32[1] = (psF32) (row + image->row0);
-    x->n = 2;
     psF32 tmpF;
     pmModelFunc modelFunc;
@@ -143,5 +141,4 @@
 
     psVector *x = psVectorAlloc(2, PS_TYPE_F32);
-    x->n = 2;
     psVector *params = model->params;
     pmModelFunc modelFunc = pmModelFunc_GetFunction (model->type);
Index: /trunk/psModules/src/objects/pmPSF.c
===================================================================
--- /trunk/psModules/src/objects/pmPSF.c	(revision 9729)
+++ /trunk/psModules/src/objects/pmPSF.c	(revision 9730)
@@ -6,6 +6,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-14 00:55:43 $
+ *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:55:05 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -121,5 +121,4 @@
 
     psf->params = psArrayAlloc(Nparams - 4);
-    psf->params->n = psf->params->nalloc;
 
     // the order of the PSF parameter (X,Y) fits is determined by the
@@ -166,8 +165,4 @@
     psVector *z  = psVectorAlloc (models->n, PS_TYPE_F64);
     psVector *dz = psVectorAlloc (models->n, PS_TYPE_F64);
-    x->n = x->nalloc;
-    y->n = y->nalloc;
-    z->n = z->nalloc;
-    dz->n = dz->nalloc;
 
     for (int i = 0; i < models->n; i++) {
@@ -258,5 +253,5 @@
 
 /***********************************************
- * this function masks the psf.ApTrend polynomial 
+ * this function masks the psf.ApTrend polynomial
  * to enable the specific subset of the coefficients
  **********************************************/
Index: /trunk/psModules/src/objects/pmPSFtry.c
===================================================================
--- /trunk/psModules/src/objects/pmPSFtry.c	(revision 9729)
+++ /trunk/psModules/src/objects/pmPSFtry.c	(revision 9730)
@@ -5,6 +5,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-17 02:21:03 $
+ *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:55:05 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -71,6 +71,4 @@
     test->fitMag   = psVectorAlloc (sources->n, PS_TYPE_F64);
     test->mask     = psVectorAlloc (sources->n, PS_TYPE_U8);
-    test->metric->n = test->fitMag->n = test->mask->n = sources->n;
-    test->modelEXT->n = test->modelPSF->n = sources->n;
 
     for (int i = 0; i < test->modelEXT->n; i++) {
@@ -196,5 +194,4 @@
     psVector *chisq = psVectorAlloc (psfTry->sources->n, PS_TYPE_F64);
     psVector *mask  = psVectorAlloc (psfTry->sources->n, PS_TYPE_MASK);
-    flux->n = mask->n = chisq->n = psfTry->sources->n;
 
     // write sources with models first
@@ -256,5 +253,4 @@
     // r2rflux = radius^2 * ten(0.4*fitMag);
     psVector *r2rflux = psVectorAlloc (psfTry->sources->n, PS_TYPE_F64);
-    r2rflux->n = psfTry->sources->n;
 
     for (int i = 0; i < psfTry->sources->n; i++) {
Index: /trunk/psModules/src/objects/pmPeaks.c
===================================================================
--- /trunk/psModules/src/objects/pmPeaks.c	(revision 9729)
+++ /trunk/psModules/src/objects/pmPeaks.c	(revision 9730)
@@ -6,6 +6,6 @@
  *  @author EAM, IfA: significant modifications.
  *
- *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-09-15 09:49:01 $
+ *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:55:05 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -40,6 +40,5 @@
 
     if (list == NULL) {
-        list = psArrayAlloc(100);
-        list->n = 0;
+        list = psArrayAllocEmpty(100);
     }
     psArrayAdd(list, 100, tmpPeak);
@@ -69,5 +68,4 @@
         tmpVector->data.F32[col] = image->data.F32[row][col];
     }
-    tmpVector->n = image->numCols;
     psTrace("psModules.objects", 4, "---- %s() end ----\n", __func__);
     return(tmpVector);
@@ -194,9 +192,7 @@
     if (n == 1) {
         psVector *tmpVector = NULL;
-        ;
         if (vector->data.F32[0] > threshold) {
             tmpVector = psVectorAlloc(1, PS_TYPE_U32);
             tmpVector->data.U32[0] = 0;
-            tmpVector->n = 1;
         } else {
             tmpVector = psVectorAlloc(0, PS_TYPE_U32);
@@ -238,5 +234,4 @@
     //
     psVector *tmpVector = psVectorAlloc(count, PS_TYPE_U32);
-    tmpVector->n = count;
     count = 0;
 
@@ -544,6 +539,5 @@
     PS_ASSERT_PTR_NON_NULL(peaks, NULL);
 
-    psArray *output = psArrayAlloc (200);
-    output->n = 0;
+    psArray *output = psArrayAllocEmpty (200);
 
     psTrace (".pmObjects.pmCullPeaks", 3, "list size is %ld\n", peaks->n);
Index: /trunk/psModules/src/objects/pmSource.c
===================================================================
--- /trunk/psModules/src/objects/pmSource.c	(revision 9729)
+++ /trunk/psModules/src/objects/pmSource.c	(revision 9730)
@@ -6,6 +6,6 @@
  *  @author EAM, IfA: significant modifications.
  *
- *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-19 21:10:08 $
+ *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:55:05 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -294,8 +294,6 @@
         maxSy = clump->y * SCALE + 0.2;
 
-        tmpSx = psVectorAlloc (sources->n, PS_TYPE_F32);
-        tmpSy = psVectorAlloc (sources->n, PS_TYPE_F32);
-        tmpSx->n = 0;
-        tmpSy->n = 0;
+        tmpSx = psVectorAllocEmpty (sources->n, PS_TYPE_F32);
+        tmpSy = psVectorAllocEmpty (sources->n, PS_TYPE_F32);
 
         // XXX clip sources based on flux?
@@ -375,6 +373,5 @@
 
     // report stats on S/N values for star-like objects
-    psVector *starsn = psVectorAlloc (sources->n, PS_TYPE_F32);
-    starsn->n = 0;
+    psVector *starsn = psVectorAllocEmpty (sources->n, PS_TYPE_F32);
 
     // check return status value (do these exist?)
Index: /trunk/psModules/src/objects/pmSourceContour.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceContour.c	(revision 9729)
+++ /trunk/psModules/src/objects/pmSourceContour.c	(revision 9730)
@@ -6,6 +6,6 @@
  *  @author EAM, IfA: significant modifications.
  *
- *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-09-15 09:49:01 $
+ *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:55:05 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -240,6 +240,6 @@
 
     // Allocate data for x/y pairs.
-    psVector *xVec = psVectorAlloc(100, PS_TYPE_F32);
-    psVector *yVec = psVectorAlloc(100, PS_TYPE_F32);
+    psVector *xVec = psVectorAllocEmpty(100, PS_TYPE_F32);
+    psVector *yVec = psVectorAllocEmpty(100, PS_TYPE_F32);
 
     // First row: find the left and right end-points
@@ -327,5 +327,4 @@
     // fprintf (stderr, "done\n");
     psArray *tmpArray = psArrayAlloc(2);
-    tmpArray->n = 2;
 
     tmpArray->data[0] = (psPtr *) xVec;
@@ -338,5 +337,5 @@
     pmSourceContour(src, img, level, mode): For an input subImage, and model, this
     routine returns a psArray of coordinates that evaluate to the specified level.
-     
+ 
     XXX: Probably should remove the "image" argument.
     XXX: What type should the output coordinate vectors consist of?  col,row?
@@ -366,5 +365,4 @@
     psVector *xVec = psVectorAlloc(2 * source->pixels->numRows, PS_TYPE_F32);
     psVector *yVec = psVectorAlloc(2 * source->pixels->numRows, PS_TYPE_F32);
-    xVec->n = yVec->n = 2 * source->pixels->numRows;
 
     //
@@ -447,5 +445,4 @@
     //
     psArray *tmpArray = psArrayAlloc(2);
-    tmpArray->n = 2;
 
     tmpArray->data[0] = (psPtr *) yVec;
Index: /trunk/psModules/src/objects/pmSourceFitModel.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceFitModel.c	(revision 9729)
+++ /trunk/psModules/src/objects/pmSourceFitModel.c	(revision 9730)
@@ -6,6 +6,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-13 22:11:02 $
+ *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:55:05 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -78,7 +78,7 @@
 
     // construct the coordinate and value entries
-    psArray *x = psArrayAlloc(nPix);
-    psVector *y = psVectorAlloc(nPix, PS_TYPE_F32);
-    psVector *yErr = psVectorAlloc(nPix, PS_TYPE_F32);
+    psArray *x = psArrayAllocEmpty(nPix);
+    psVector *y = psVectorAllocEmpty(nPix, PS_TYPE_F32);
+    psVector *yErr = psVectorAllocEmpty(nPix, PS_TYPE_F32);
 
     nPix = 0;
@@ -95,5 +95,4 @@
 
             psVector *coord = psVectorAlloc(2, PS_TYPE_F32);
-            coord->n = 2;
 
             // Convert i/j to image space:
@@ -128,5 +127,4 @@
     // set parameter mask based on fitting mode
     paramMask = psVectorAlloc (params->n, PS_TYPE_U8);
-    paramMask->n = params->n;
     psVectorInit (paramMask, 1);
 
@@ -208,5 +206,4 @@
     if (paramMask != NULL) {
         psVector *delta = psVectorAlloc (params->n, PS_TYPE_F64);
-        delta->n = params->n;
         psMinimizeGaussNewtonDelta(delta, params, NULL, x, y, yErr, modelFunc);
         for (int i = 0; i < dparams->n; i++) {
@@ -272,5 +269,4 @@
     onePar = psVectorAlloc (nPar, PS_DATA_F32);
     oneDeriv = psVectorAlloc (nPar, PS_DATA_F32);
-    onePar->n = oneDeriv->n = nPar;
 
     return true;
@@ -357,6 +353,4 @@
     psVector *params = psVectorAlloc (nSrc*nPar + 1, PS_TYPE_F32);
     psVector *dparams = psVectorAlloc (nSrc*nPar + 1, PS_TYPE_F32);
-    params->n = params->nalloc;
-    dparams->n = dparams->nalloc;
 
     pmModelLimits modelLimits = pmModelLimits_GetFunction (model->type);
@@ -373,8 +367,4 @@
     constrain->paramMask = psVectorAlloc (nSrc*nPar + 1, PS_TYPE_U8);
     constrain->paramDelta = psVectorAlloc (nSrc*nPar + 1, PS_TYPE_F32);
-    constrain->paramMin->n = constrain->paramMin->nalloc;
-    constrain->paramMax->n = constrain->paramMax->nalloc;
-    constrain->paramMask->n = constrain->paramMask->nalloc;
-    constrain->paramDelta->n = constrain->paramDelta->nalloc;
 
     // set the parameter guesses and constraints for the multiple models
@@ -459,7 +449,7 @@
 
     // construct the coordinate and value entries
-    psArray *x = psArrayAlloc(nPix);
-    psVector *y = psVectorAlloc(nPix, PS_TYPE_F32);
-    psVector *yErr = psVectorAlloc(nPix, PS_TYPE_F32);
+    psArray *x = psArrayAllocEmpty(nPix);
+    psVector *y = psVectorAllocEmpty(nPix, PS_TYPE_F32);
+    psVector *yErr = psVectorAllocEmpty(nPix, PS_TYPE_F32);
 
     nPix = 0;
@@ -475,5 +465,4 @@
             }
             psVector *coord = psVectorAlloc(2, PS_TYPE_F32);
-            coord->n = 2;
 
             // Convert i/j to image space:
@@ -534,5 +523,4 @@
     if (constrain->paramMask != NULL) {
         psVector *delta = psVectorAlloc (params->n, PS_TYPE_F64);
-        delta->n = params->n;
         psMinimizeGaussNewtonDelta(delta, params, NULL, x, y, yErr, pmModelFitSet);
         for (int i = 0; i < dparams->n; i++) {
Index: /trunk/psModules/src/objects/pmSourceIO_CMF.c
===================================================================
--- /trunk/psModules/src/objects/pmSourceIO_CMF.c	(revision 9729)
+++ /trunk/psModules/src/objects/pmSourceIO_CMF.c	(revision 9730)
@@ -3,6 +3,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-19 21:16:49 $
+ *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:55:05 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -50,6 +50,5 @@
     float ZERO_POINT = psMetadataLookupF32 (&status, header, "ZERO_PT");
 
-    table = psArrayAlloc (sources->n);
-    table->n = 0;
+    table = psArrayAllocEmpty (sources->n);
 
     for (i = 0; i < sources->n; i++) {
@@ -130,5 +129,4 @@
 
     psArray *sources = psArrayAlloc (table->n);
-    sources->n = table->n;
 
     // convert the table to the pmSource entries
Index: /trunk/psModules/src/objects/pmSourcePhotometry.c
===================================================================
--- /trunk/psModules/src/objects/pmSourcePhotometry.c	(revision 9729)
+++ /trunk/psModules/src/objects/pmSourcePhotometry.c	(revision 9730)
@@ -3,6 +3,6 @@
  *  @author EAM, IfA; GLG, MHPCC
  *
- *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-17 02:21:03 $
+ *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:55:05 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -241,5 +241,4 @@
     pmModelFunc modelFunc = pmModelFunc_GetFunction (model->type);
     psVector *coord = psVectorAlloc(2, PS_TYPE_F32);
-    coord->n = 2;
 
     psVector *params = model->params;
