Index: trunk/psLib/src/astro/psCoord.c
===================================================================
--- trunk/psLib/src/astro/psCoord.c	(revision 12329)
+++ trunk/psLib/src/astro/psCoord.c	(revision 12330)
@@ -10,6 +10,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.134 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2007-02-07 23:52:53 $
+*  @version $Revision: 1.135 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2007-03-08 22:12:56 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -67,7 +67,7 @@
 simply inverts the supplied psPlaneTransform transform.  It assumes that
 "transform" is linear.
- 
+
 XXX: This code no longer makes sense.  The merge must be reviewed.
- 
+
 XXX: below is the code using the standard matrix representation.  note that
 this inversion requires x->nX == 1, y->nY == 1 and x->nY <= 1, y->nX <= 1
@@ -144,9 +144,9 @@
 if the supplied psPlaneTransform transform is linear: if any of the
 cooefficients of order 2 are higher are non-zero, then it is not linear.
- 
+
 Returns:
     true: if linear
     false: otherwise
- 
+
 Why isn't this called p_psIsPlaneTransformLinear()?
  *****************************************************************************/
@@ -882,5 +882,5 @@
 /*****************************************************************************
 psPlaneTransformFit(trans, source, dest, nRejIter, sigmaClip)
- 
+
 XXX: This code ignores nRejIter and sigmaClip.  We must call the ClipFit
 routines instead.
@@ -931,5 +931,5 @@
 /*****************************************************************************
 psPlaneTransformInvert(out, in, region, nSamples)
- 
+
  *****************************************************************************/
 psPlaneTransform *psPlaneTransformInvert(
@@ -1129,6 +1129,6 @@
                     //                    out->data[m].y = fxnVal->y + y;
                     //                    m++;
-                    out = p_psPixelsAppend(out, 1, (float)(fxnVal->x+j),
-                                           (float)(fxnVal->y+k) );
+                    out = psPixelsAdd(out, 1, (float)(fxnVal->x+j),
+                                      (float)(fxnVal->y+k) );
                 }
             }
Index: trunk/psLib/src/imageops/psImageGeomManip.c
===================================================================
--- trunk/psLib/src/imageops/psImageGeomManip.c	(revision 12329)
+++ trunk/psLib/src/imageops/psImageGeomManip.c	(revision 12330)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-03-06 02:14:55 $
+ *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-03-08 22:12:56 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -907,5 +907,5 @@
     if (isnan(value)) { \
         if (blankPixels != NULL) { \
-            p_psPixelsAppend(*blankPixels, (*blankPixels)->nalloc, outPosition.x, outPosition.y); \
+            psPixelsAdd(*blankPixels, (*blankPixels)->nalloc, outPosition.x, outPosition.y); \
         } \
         value = exposedValue; \
Index: trunk/psLib/src/types/psPixels.c
===================================================================
--- trunk/psLib/src/types/psPixels.c	(revision 12329)
+++ trunk/psLib/src/types/psPixels.c	(revision 12330)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-03-07 02:50:15 $
+ *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-03-08 22:12:56 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -60,4 +60,19 @@
 }
 
+
+static psPixels *pixelsAlloc(const char *file,
+                          unsigned int lineno,
+                          const char *func,
+                          long nalloc)
+{
+    psPixels* out = p_psAlloc(file, lineno, func, sizeof(psPixels));
+    psMemSetDeallocator(out, (psFreeFunc)pixelsFree);
+
+    out->data = p_psAlloc(file, lineno, func, sizeof(psPixelCoord)*nalloc);
+    P_PSPIXELS_SET_NALLOC(out,nalloc);
+
+    return out;
+}
+
 psPixels* p_psPixelsAlloc(const char *file,
                           unsigned int lineno,
@@ -65,16 +80,16 @@
                           long nalloc)
 {
-    psPixels* out = p_psAlloc(file, lineno, func, sizeof(psPixels));
-
-    if (nalloc > 0) {
-        out->data = p_psAlloc(file, lineno, func, sizeof(psPixelCoord)*nalloc);
-    } else {
-        out->data = NULL;
-    }
+    psPixels *out = pixelsAlloc(file, lineno, func, nalloc);
+    out->n = nalloc;
+    return out;
+}
+
+psPixels* p_psPixelsAllocEmpty(const char *file,
+                             unsigned int lineno,
+                             const char *func,
+                             long nalloc)
+{
+    psPixels *out = pixelsAlloc(file, lineno, func, nalloc);
     out->n = 0;
-    P_PSPIXELS_SET_NALLOC(out,nalloc);
-
-    psMemSetDeallocator(out, (psFreeFunc)pixelsFree);
-
     return out;
 }
@@ -94,35 +109,38 @@
                             long nalloc)
 {
-    if (pixels == NULL) {
+    if (!pixels) {
         return p_psPixelsAlloc(file, lineno, func, nalloc);
     }
-
-    if (nalloc > 0) {
-        pixels->data = p_psRealloc(file, lineno, func, pixels->data, sizeof(psPixelCoord)*nalloc);
-    } else {
-        psFree(pixels->data);
-        pixels->data = NULL;
-    }
-
+    if (nalloc < 0) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                "Can't reallocate a psPixels to negative size.");
+        return pixels;
+    }
+
+    if (pixels->n == nalloc) {
+        return pixels;
+    }
+    if (nalloc < pixels->n) {
+        pixels->n = nalloc;
+    }
+    pixels->data = p_psRealloc(file, lineno, func, pixels->data, sizeof(psPixelCoord)*nalloc);
     P_PSPIXELS_SET_NALLOC(pixels,nalloc);
 
-    if (pixels->n > pixels->nalloc) {
-        pixels->n = pixels->nalloc;
-    }
-
     return pixels;
 }
 
-psPixels* p_psPixelsAppend(psPixels* pixels,
-                           long growth,
-                           float x,
-                           float y)
-{
-    if (growth < 1) {
+psPixels* psPixelsAdd(psPixels* pixels,
+                      long growth,
+                      float x,
+                      float y)
+{
+    PS_ASSERT_PIXELS_NON_NULL(pixels, NULL);
+
+    if (growth <= 0) {
         growth = PIXELS_DEFAULT_ADD;
     }
 
-    if ( (pixels == NULL) || (pixels->n >= pixels->nalloc) ) {
-        pixels=psPixelsRealloc(pixels, pixels->nalloc+growth);
+    if (pixels->n >= pixels->nalloc) {
+        pixels = psPixelsRealloc(pixels, pixels->nalloc + growth);
     }
 
@@ -354,5 +372,5 @@
         position += pixels->n;
     }
-    if (position < 0 || position > pixels->n) {
+    if (position < 0 || position >= pixels->n) {
         psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid position: %ld\n", position);
         return false;
Index: trunk/psLib/src/types/psPixels.h
===================================================================
--- trunk/psLib/src/types/psPixels.h	(revision 12329)
+++ trunk/psLib/src/types/psPixels.h	(revision 12330)
@@ -6,6 +6,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-03-07 02:50:15 $
+ *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-03-08 22:12:56 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -79,4 +79,23 @@
 #endif // ifdef DOXYGEN
 
+/** Allocates a new empty psPixels structure
+ *
+ *  @return psPixels*   new psPixels
+ */
+#ifdef DOXYGEN
+psPixels* psPixelsAllocEmpty(
+    long nalloc                         ///< the size of the coordinate vectors
+);
+#else // ifdef DOXYGEN
+psPixels* p_psPixelsAllocEmpty(
+    const char *file,                   ///< File of caller
+    unsigned int lineno,                ///< Line number of caller
+    const char *func,                   ///< Function name of caller
+    long nalloc                         ///< the size of the coordinate vectors
+);
+#define psPixelsAllocEmpty(nalloc) \
+      p_psPixelsAllocEmpty(__FILE__, __LINE__, __func__, nalloc)
+#endif // ifdef DOXYGEN
+
 
 /** Checks the type of a particular pointer.
@@ -121,5 +140,5 @@
  *  @return psPixels*       psPixels with the value appended.
  */
-psPixels* p_psPixelsAppend(
+psPixels* psPixelsAdd(
     psPixels* pixels,                  ///< psPixels to append new coordinate to.
     long growth,                       ///< Number of elements to grow the pixels list if necessary.
