Index: trunk/psLib/src/image/psImage.c
===================================================================
--- trunk/psLib/src/image/psImage.c	(revision 1440)
+++ trunk/psLib/src/image/psImage.c	(revision 1606)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-08-09 23:34:58 $
+ *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-08-23 22:36:03 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -43,13 +43,6 @@
 {
     int area = 0;
-    int elementSize = PSELEMTYPE_SIZEOF(type);  // element
-
-    // size in
-    // bytes
-    int rowSize = numCols * elementSize;        // row
-
-    // size
-
-    // in bytes.
+    int elementSize = PSELEMTYPE_SIZEOF(type);  // element size in bytes
+    int rowSize = numCols * elementSize;        // row size in bytes.
 
     area = numCols * numRows;
@@ -71,12 +64,17 @@
     image->data.V = psAlloc(sizeof(void *) * numRows);
     if (image->data.V == NULL) {
+        psFree(image);
         psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
     }
 
-    image->data.V[0] = psAlloc(area * elementSize);
-    if (image->data.V[0] == NULL) {
+    image->rawDataBuffer = psAlloc(area * elementSize);
+    if (image->rawDataBuffer == NULL) {
+        psFree(image);
+        psFree(image->data.V);
         psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__);
     }
 
+    // set the row pointers.
+    image->data.V[0] = image->rawDataBuffer;
     for (int i = 1; i < numRows; i++) {
         image->data.V[i] = (void *)((int8_t *) image->data.V[i - 1] + rowSize);
@@ -119,5 +117,5 @@
     psImageFreeChildren(image);
 
-    psFree(image->data.V[0]);
+    psFree(image->rawDataBuffer);
     psFree(image->data.V);
     image->data.V = NULL;
@@ -167,8 +165,9 @@
     }
     // Resize the image buffer
-    old->data.V[0] = psRealloc(old->data.V[0], numCols * numRows * elementSize);
+    old->rawDataBuffer = psRealloc(old->data.V[0], numCols * numRows * elementSize);
     old->data.V = (void **)psRealloc(old->data.V, numRows * sizeof(void *));
 
     // recreate the row pointers
+    old->data.V[0] = old->rawDataBuffer;
     for (int i = 1; i < numRows; i++) {
         old->data.V[i] = (void *)((int8_t *) old->data.V[i - 1] + rowSize);
