Index: /trunk/psLib/src/dataManip/psConstants.h
===================================================================
--- /trunk/psLib/src/dataManip/psConstants.h	(revision 3312)
+++ /trunk/psLib/src/dataManip/psConstants.h	(revision 3313)
@@ -6,6 +6,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.55 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-02-17 19:26:23 $
+ *  @version $Revision: 1.56 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-02-24 00:19:51 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -198,10 +198,11 @@
 } \
 
-#define PS_VECTOR_CHECK_EMPTY(NAME, RVAL) \
+#define PS_VECTOR_CHECK_EMPTY(NAME, RVAL) PS_VECTOR_CHECK_EMPTY_GENERAL(NAME, return RVAL)
+#define PS_VECTOR_CHECK_EMPTY_GENERAL(NAME, CLEANUP) \
 if (NAME->n < 1) { \
     psError(PS_ERR_BAD_PARAMETER_SIZE, true, \
             "Unallowable operation: psVector %s has no elements.", \
             #NAME); \
-    return(RVAL); \
+    CLEANUP; \
 } \
 
Index: /trunk/psLib/src/dataManip/psMatrix.c
===================================================================
--- /trunk/psLib/src/dataManip/psMatrix.c	(revision 3312)
+++ /trunk/psLib/src/dataManip/psMatrix.c	(revision 3313)
@@ -21,6 +21,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-02-19 00:30:07 $
+ *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-02-24 00:19:51 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -50,28 +50,28 @@
 
 /** Preprocessor macro to generate error for image dimensionality not set to PS_DIMEN_IMAGE */
-#define PS_CHECK_DIMEN_AND_TYPE(NAME, PS_DIMEN, RETURN)                                             \
+#define PS_CHECK_DIMEN_AND_TYPE(NAME, PS_DIMEN, CLEANUP)                                             \
 if (NAME->type.dimen != PS_DIMEN) {                                                                 \
     psError(PS_ERR_BAD_PARAMETER_TYPE, true,                                                        \
             "Invalid operation. %s has incorrect dimensionality %d.", #NAME, PS_DIMEN);             \
-    return RETURN;                                                                                  \
+    CLEANUP;                                                                                  \
 } else if(NAME->type.type!=PS_TYPE_F64 && NAME->type.type!=PS_TYPE_F32) {                           \
     psError(PS_ERR_BAD_PARAMETER_TYPE, true,                                                        \
             "Invalid operation. %s not PS_TYPE_F64.", #NAME);                                       \
-    return RETURN;                                                                                  \
+    CLEANUP;                                                                                  \
 }
 
 /** Preprocessor macro to check that input is not equal to output */
-#define PS_CHECK_POINTERS(NAME1, NAME2, RETURN)                                                     \
+#define PS_CHECK_POINTERS(NAME1, NAME2, CLEANUP)                                                     \
 if (NAME1 == NAME2) {                                                                               \
     psError(PS_ERR_BAD_PARAMETER_VALUE, true,                                                       \
             "Invalid operation: Pointer to %s is same as %s.", #NAME1, #NAME2);                     \
-    return RETURN;                                                                                  \
+    CLEANUP;                                                                                  \
 }
 
 /** Preprocessor macro to check that an image is square */
-#define PS_CHECK_SQUARE(NAME, RETURN)                                                               \
+#define PS_CHECK_SQUARE(NAME, CLEANUP)                                                               \
 if (NAME->numCols != NAME->numRows) {                                                               \
     psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid operation: %s not square array.", #NAME);     \
-    return RETURN;                                                                                  \
+    CLEANUP;                                                                                  \
 }
 
@@ -189,12 +189,12 @@
     // Error checks
     PS_IMAGE_CHECK_NULL_GENERAL(inImage, psMatrixLUD_EXIT);
-    PS_CHECK_POINTERS(inImage, outImage, outImage);
-    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outImage);
+    PS_CHECK_POINTERS(inImage, outImage, psMatrixLUD_EXIT);
+    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, psMatrixLUD_EXIT);
     PS_PTR_CHECK_NULL_GENERAL(outPerm, psMatrixLUD_EXIT);
 
     outImage = psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type);
 
-    PS_CHECK_SQUARE(inImage, outImage);
-    PS_CHECK_SQUARE(outImage, outImage);
+    PS_CHECK_SQUARE(inImage, psMatrixLUD_EXIT);
+    PS_CHECK_SQUARE(outImage, psMatrixLUD_EXIT);
 
     // Initialize data
@@ -244,17 +244,19 @@
     gsl_vector *x = NULL;
 
-    // Error checks
-    PS_CHECK_POINTERS(outVector, inVector, outVector);
-    PS_CHECK_POINTERS(inVector, inPerm, outVector);
-    PS_CHECK_POINTERS(outVector, inPerm, outVector);
-    PS_IMAGE_CHECK_NULL(inImage, outVector);
-    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outVector);
-    PS_IMAGE_CHECK_EMPTY(inImage, outVector);
-    PS_VECTOR_CHECK_NULL(outVector, outVector);
-    PS_CHECK_DIMEN_AND_TYPE(outVector, PS_DIMEN_VECTOR, outVector);
-    PS_VECTOR_CHECK_NULL(inVector, outVector);
-    PS_CHECK_DIMEN_AND_TYPE(inVector, PS_DIMEN_VECTOR, outVector);
-    PS_VECTOR_CHECK_NULL(inPerm, outVector);
-    psVectorRecycle(outVector, inImage->numRows, inImage->type.type);
+    #define LUSOLVE_CLEANUP {psFree(outVector); return NULL;}
+
+    // Error checks
+    PS_IMAGE_CHECK_NULL_GENERAL(inImage, LUSOLVE_CLEANUP);
+    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, LUSOLVE_CLEANUP);
+    PS_IMAGE_CHECK_EMPTY_GENERAL(inImage, LUSOLVE_CLEANUP);
+    PS_VECTOR_CHECK_NULL_GENERAL(inVector, LUSOLVE_CLEANUP);
+    PS_CHECK_DIMEN_AND_TYPE(inVector, PS_DIMEN_VECTOR, LUSOLVE_CLEANUP);
+    PS_VECTOR_CHECK_NULL_GENERAL(inPerm, LUSOLVE_CLEANUP);
+
+    outVector = psVectorRecycle(outVector, inImage->numRows, inImage->type.type);
+
+    PS_CHECK_POINTERS(outVector, inVector, LUSOLVE_CLEANUP);
+    PS_CHECK_POINTERS(inVector, inPerm, LUSOLVE_CLEANUP);
+    PS_CHECK_POINTERS(outVector, inPerm, LUSOLVE_CLEANUP);
 
     // Initialize data
@@ -296,13 +298,16 @@
     gsl_permutation *perm = NULL;
 
-    // Error checks
-    PS_PTR_CHECK_NULL(det, outImage);
-    PS_CHECK_POINTERS(inImage, outImage, outImage);
-    PS_IMAGE_CHECK_NULL(inImage, outImage);
-    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outImage);
-    PS_IMAGE_CHECK_EMPTY(inImage, outImage);
+    #define INVERT_CLEANUP { psFree(outImage); return NULL; }
+    // Error checks
+    PS_PTR_CHECK_NULL_GENERAL(det, INVERT_CLEANUP);
+    PS_IMAGE_CHECK_NULL_GENERAL(inImage, INVERT_CLEANUP);
+    PS_CHECK_POINTERS(inImage, outImage, INVERT_CLEANUP);
+    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, INVERT_CLEANUP);
+    PS_IMAGE_CHECK_EMPTY_GENERAL(inImage, INVERT_CLEANUP);
+
     outImage = psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type);
-    PS_CHECK_SQUARE(inImage, outImage);
-    PS_CHECK_SQUARE(outImage, outImage);
+
+    PS_CHECK_SQUARE(inImage, INVERT_CLEANUP);
+    PS_CHECK_SQUARE(outImage, INVERT_CLEANUP);
 
     // Initialize data
@@ -341,9 +346,10 @@
     gsl_permutation *perm = NULL;
 
-    // Error checks
-    PS_IMAGE_CHECK_NULL(inImage, NULL);
-    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, NULL);
-    PS_IMAGE_CHECK_EMPTY(inImage, NULL);
-    PS_CHECK_SQUARE(inImage, 0);
+    #define DETERMINANT_EXIT { return NULL; }
+    // Error checks
+    PS_IMAGE_CHECK_NULL_GENERAL(inImage, DETERMINANT_EXIT);
+    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, DETERMINANT_EXIT);
+    PS_IMAGE_CHECK_EMPTY_GENERAL(inImage, DETERMINANT_EXIT);
+    PS_CHECK_SQUARE(inImage, DETERMINANT_EXIT);
 
     // Initialize data
@@ -376,20 +382,21 @@
     gsl_matrix *m3 = NULL;
 
-    // Error checks
-    PS_CHECK_POINTERS(inImage1, outImage, outImage);
-    PS_CHECK_POINTERS(inImage1, inImage2, outImage);
-    PS_IMAGE_CHECK_NULL(inImage1, outImage);
-    PS_CHECK_DIMEN_AND_TYPE(inImage1, PS_DIMEN_IMAGE, outImage);
-    PS_IMAGE_CHECK_EMPTY(inImage1, outImage);
-    PS_IMAGE_CHECK_NULL(inImage2, outImage);
-    PS_CHECK_DIMEN_AND_TYPE(inImage2, PS_DIMEN_IMAGE, outImage);
-    PS_IMAGE_CHECK_EMPTY(inImage2, outImage);
-    PS_CHECK_DIMEN_AND_TYPE(inImage1, PS_DIMEN_IMAGE, outImage);
+    #define MULTIPLY_CLEANUP { psFree(outImage); return NULL; }
+
+    // Error checks
+    PS_IMAGE_CHECK_NULL_GENERAL(inImage1, MULTIPLY_CLEANUP);
+    PS_IMAGE_CHECK_NULL_GENERAL(inImage2, MULTIPLY_CLEANUP);
+    PS_IMAGE_CHECK_EMPTY_GENERAL(inImage1, MULTIPLY_CLEANUP);
+    PS_IMAGE_CHECK_EMPTY_GENERAL(inImage2, MULTIPLY_CLEANUP);
+    PS_CHECK_DIMEN_AND_TYPE(inImage1, PS_DIMEN_IMAGE, MULTIPLY_CLEANUP);
+    PS_CHECK_DIMEN_AND_TYPE(inImage2, PS_DIMEN_IMAGE, MULTIPLY_CLEANUP);
+    PS_CHECK_POINTERS(inImage1, outImage, MULTIPLY_CLEANUP);
+    PS_CHECK_POINTERS(inImage1, inImage2, MULTIPLY_CLEANUP);
 
     outImage = psImageRecycle(outImage, inImage2->numCols, inImage2->numRows, inImage2->type.type);
 
-    PS_CHECK_SQUARE(inImage1, outImage);
-    PS_CHECK_SQUARE(inImage2, outImage);
-    PS_CHECK_SQUARE(outImage, outImage);
+    PS_CHECK_SQUARE(inImage1, MULTIPLY_CLEANUP);
+    PS_CHECK_SQUARE(inImage2, MULTIPLY_CLEANUP);
+    PS_CHECK_SQUARE(outImage, MULTIPLY_CLEANUP);
 
     // Initialize data
@@ -428,10 +435,11 @@
     psS32 numColsOut = 0;
 
-
-    // Error checks
-    PS_CHECK_POINTERS(inImage, outImage, outImage);
-    PS_IMAGE_CHECK_NULL(inImage, outImage);
-    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outImage);
-    PS_IMAGE_CHECK_EMPTY(inImage, outImage);
+    #define TRANSPOSE_CLEANUP { psFree(outImage); return NULL; }
+    // Error checks
+    PS_IMAGE_CHECK_NULL_GENERAL(inImage, TRANSPOSE_CLEANUP);
+    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, TRANSPOSE_CLEANUP);
+    PS_IMAGE_CHECK_EMPTY_GENERAL(inImage, TRANSPOSE_CLEANUP);
+    PS_CHECK_POINTERS(inImage, outImage, TRANSPOSE_CLEANUP);
+
     outImage = psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type);
 
@@ -472,10 +480,10 @@
     gsl_matrix *in = NULL;
 
-
-    // Error checks
-    PS_CHECK_POINTERS(inImage, outImage, outImage);
-    PS_IMAGE_CHECK_NULL(inImage, outImage);
-    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outImage);
-    PS_IMAGE_CHECK_EMPTY(inImage, outImage);
+    #define EIGENVECTORS_CLEANUP { psFree(outImage); return NULL; }
+    // Error checks
+    PS_IMAGE_CHECK_NULL_GENERAL(inImage, EIGENVECTORS_CLEANUP);
+    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, EIGENVECTORS_CLEANUP);
+    PS_IMAGE_CHECK_EMPTY_GENERAL(inImage, EIGENVECTORS_CLEANUP);
+    PS_CHECK_POINTERS(inImage, outImage, EIGENVECTORS_CLEANUP);
 
     outImage = psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type);
@@ -494,6 +502,6 @@
 
     // Non-square matrices not allowed
-    PS_CHECK_SQUARE(inImage, outImage);
-    PS_CHECK_SQUARE(outImage, outImage);
+    PS_CHECK_SQUARE(inImage, EIGENVECTORS_CLEANUP);
+    PS_CHECK_SQUARE(outImage, EIGENVECTORS_CLEANUP);
 
     // Calculate Eigenvalues and Eigenvectors...Eigenvalues not currently used
@@ -520,14 +528,14 @@
     // Error checks
     PS_IMAGE_CHECK_NULL_GENERAL(inImage, psMatrixToVector_EXIT);
-    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outVector);
+    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, psMatrixToVector_EXIT);
     PS_IMAGE_CHECK_EMPTY_GENERAL(inImage, psMatrixToVector_EXIT);
 
     if (inImage->numRows == 1) {
         // Create transposed row vector
-        psVectorRecycle(outVector, inImage->numCols, inImage->type.type);
+        outVector = psVectorRecycle(outVector, inImage->numCols, inImage->type.type);
         outVector->type.dimen = PS_DIMEN_TRANSV;
     } else if (inImage->numCols == 1) {
         // Create non-transposed column vector
-        psVectorRecycle(outVector, inImage->numRows, inImage->type.type);
+        outVector = psVectorRecycle(outVector, inImage->numRows, inImage->type.type);
     } else {
         psError(PS_ERR_BAD_PARAMETER_SIZE, true,
@@ -537,9 +545,7 @@
     }
 
-    PS_VECTOR_CHECK_NULL(outVector, outVector);
-
     // More checks
     if (outVector->type.dimen == PS_DIMEN_VECTOR) {
-        PS_CHECK_DIMEN_AND_TYPE(outVector, PS_DIMEN_VECTOR, outVector);
+        PS_CHECK_DIMEN_AND_TYPE(outVector, PS_DIMEN_VECTOR, psMatrixToVector_EXIT);
 
         if (outVector->n == 0) {
@@ -557,5 +563,5 @@
 
     } else if (outVector->type.dimen == PS_DIMEN_TRANSV) {
-        PS_CHECK_DIMEN_AND_TYPE(outVector, PS_DIMEN_TRANSV, outVector);
+        PS_CHECK_DIMEN_AND_TYPE(outVector, PS_DIMEN_TRANSV, psMatrixToVector_EXIT);
 
         if (outVector->n == 0) {
@@ -582,11 +588,14 @@
     psS32 size = 0;
 
-    // Error checks
-    PS_VECTOR_CHECK_NULL(inVector, outImage);
+    #define VECTORTOMATRIX_CLEANUP {psFree(outImage); return NULL; }
+    // Error checks
+    PS_VECTOR_CHECK_NULL_GENERAL(inVector, VECTORTOMATRIX_CLEANUP);
 
     if (inVector->type.dimen == PS_DIMEN_VECTOR) {
-        PS_CHECK_DIMEN_AND_TYPE(inVector, PS_DIMEN_VECTOR, outImage);
-        PS_VECTOR_CHECK_EMPTY(inVector, outImage);
+        PS_CHECK_DIMEN_AND_TYPE(inVector, PS_DIMEN_VECTOR, VECTORTOMATRIX_CLEANUP);
+        PS_VECTOR_CHECK_EMPTY_GENERAL(inVector, VECTORTOMATRIX_CLEANUP);
+
         outImage = psImageRecycle(outImage, 1, inVector->n, inVector->type.type);
+
         // More checks for PS_DIMEN_VECTOR
         if (outImage->numCols > 1) {
@@ -605,6 +614,6 @@
 
     } else if (inVector->type.dimen == PS_DIMEN_TRANSV) {
-        PS_CHECK_DIMEN_AND_TYPE(inVector, PS_DIMEN_TRANSV, outImage);
-        PS_VECTOR_CHECK_EMPTY(inVector, outImage);
+        PS_CHECK_DIMEN_AND_TYPE(inVector, PS_DIMEN_TRANSV, VECTORTOMATRIX_CLEANUP);
+        PS_VECTOR_CHECK_EMPTY_GENERAL(inVector, VECTORTOMATRIX_CLEANUP);
         outImage = psImageRecycle(outImage, inVector->n, 1, inVector->type.type);
         // More checks for PS_DIMEN_TRANSV
@@ -624,6 +633,6 @@
     }
 
-    PS_IMAGE_CHECK_NULL(outImage, outImage);
-    PS_CHECK_DIMEN_AND_TYPE(outImage, PS_DIMEN_IMAGE, outImage);
+    PS_IMAGE_CHECK_NULL_GENERAL(outImage, VECTORTOMATRIX_CLEANUP);
+    PS_CHECK_DIMEN_AND_TYPE(outImage, PS_DIMEN_IMAGE, VECTORTOMATRIX_CLEANUP);
 
     memcpy(outImage->data.V[0], inVector->data.V, size);
Index: /trunk/psLib/src/image/psImageExtraction.c
===================================================================
--- /trunk/psLib/src/image/psImageExtraction.c	(revision 3312)
+++ /trunk/psLib/src/image/psImageExtraction.c	(revision 3313)
@@ -9,6 +9,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-02-23 21:32:40 $
+ *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-02-24 00:19:51 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -556,9 +556,9 @@
     psF32* cutRowsData = NULL;
     if (cutCols != NULL) {
-        (void)psVectorRecycle(cutCols, nSamples, PS_TYPE_F32);
+        cutCols = psVectorRecycle(cutCols, nSamples, PS_TYPE_F32);
         cutColsData = cutCols->data.F32;
     }
     if (cutRows != NULL) {
-        (void)psVectorRecycle(cutRows, nSamples, PS_TYPE_F32);
+        cutRows = psVectorRecycle(cutRows, nSamples, PS_TYPE_F32);
         cutRowsData = cutRows->data.F32;
     }
Index: /trunk/psLib/src/math/psConstants.h
===================================================================
--- /trunk/psLib/src/math/psConstants.h	(revision 3312)
+++ /trunk/psLib/src/math/psConstants.h	(revision 3313)
@@ -6,6 +6,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.55 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-02-17 19:26:23 $
+ *  @version $Revision: 1.56 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-02-24 00:19:51 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -198,10 +198,11 @@
 } \
 
-#define PS_VECTOR_CHECK_EMPTY(NAME, RVAL) \
+#define PS_VECTOR_CHECK_EMPTY(NAME, RVAL) PS_VECTOR_CHECK_EMPTY_GENERAL(NAME, return RVAL)
+#define PS_VECTOR_CHECK_EMPTY_GENERAL(NAME, CLEANUP) \
 if (NAME->n < 1) { \
     psError(PS_ERR_BAD_PARAMETER_SIZE, true, \
             "Unallowable operation: psVector %s has no elements.", \
             #NAME); \
-    return(RVAL); \
+    CLEANUP; \
 } \
 
Index: /trunk/psLib/src/math/psMatrix.c
===================================================================
--- /trunk/psLib/src/math/psMatrix.c	(revision 3312)
+++ /trunk/psLib/src/math/psMatrix.c	(revision 3313)
@@ -21,6 +21,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-02-19 00:30:07 $
+ *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-02-24 00:19:51 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -50,28 +50,28 @@
 
 /** Preprocessor macro to generate error for image dimensionality not set to PS_DIMEN_IMAGE */
-#define PS_CHECK_DIMEN_AND_TYPE(NAME, PS_DIMEN, RETURN)                                             \
+#define PS_CHECK_DIMEN_AND_TYPE(NAME, PS_DIMEN, CLEANUP)                                             \
 if (NAME->type.dimen != PS_DIMEN) {                                                                 \
     psError(PS_ERR_BAD_PARAMETER_TYPE, true,                                                        \
             "Invalid operation. %s has incorrect dimensionality %d.", #NAME, PS_DIMEN);             \
-    return RETURN;                                                                                  \
+    CLEANUP;                                                                                  \
 } else if(NAME->type.type!=PS_TYPE_F64 && NAME->type.type!=PS_TYPE_F32) {                           \
     psError(PS_ERR_BAD_PARAMETER_TYPE, true,                                                        \
             "Invalid operation. %s not PS_TYPE_F64.", #NAME);                                       \
-    return RETURN;                                                                                  \
+    CLEANUP;                                                                                  \
 }
 
 /** Preprocessor macro to check that input is not equal to output */
-#define PS_CHECK_POINTERS(NAME1, NAME2, RETURN)                                                     \
+#define PS_CHECK_POINTERS(NAME1, NAME2, CLEANUP)                                                     \
 if (NAME1 == NAME2) {                                                                               \
     psError(PS_ERR_BAD_PARAMETER_VALUE, true,                                                       \
             "Invalid operation: Pointer to %s is same as %s.", #NAME1, #NAME2);                     \
-    return RETURN;                                                                                  \
+    CLEANUP;                                                                                  \
 }
 
 /** Preprocessor macro to check that an image is square */
-#define PS_CHECK_SQUARE(NAME, RETURN)                                                               \
+#define PS_CHECK_SQUARE(NAME, CLEANUP)                                                               \
 if (NAME->numCols != NAME->numRows) {                                                               \
     psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Invalid operation: %s not square array.", #NAME);     \
-    return RETURN;                                                                                  \
+    CLEANUP;                                                                                  \
 }
 
@@ -189,12 +189,12 @@
     // Error checks
     PS_IMAGE_CHECK_NULL_GENERAL(inImage, psMatrixLUD_EXIT);
-    PS_CHECK_POINTERS(inImage, outImage, outImage);
-    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outImage);
+    PS_CHECK_POINTERS(inImage, outImage, psMatrixLUD_EXIT);
+    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, psMatrixLUD_EXIT);
     PS_PTR_CHECK_NULL_GENERAL(outPerm, psMatrixLUD_EXIT);
 
     outImage = psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type);
 
-    PS_CHECK_SQUARE(inImage, outImage);
-    PS_CHECK_SQUARE(outImage, outImage);
+    PS_CHECK_SQUARE(inImage, psMatrixLUD_EXIT);
+    PS_CHECK_SQUARE(outImage, psMatrixLUD_EXIT);
 
     // Initialize data
@@ -244,17 +244,19 @@
     gsl_vector *x = NULL;
 
-    // Error checks
-    PS_CHECK_POINTERS(outVector, inVector, outVector);
-    PS_CHECK_POINTERS(inVector, inPerm, outVector);
-    PS_CHECK_POINTERS(outVector, inPerm, outVector);
-    PS_IMAGE_CHECK_NULL(inImage, outVector);
-    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outVector);
-    PS_IMAGE_CHECK_EMPTY(inImage, outVector);
-    PS_VECTOR_CHECK_NULL(outVector, outVector);
-    PS_CHECK_DIMEN_AND_TYPE(outVector, PS_DIMEN_VECTOR, outVector);
-    PS_VECTOR_CHECK_NULL(inVector, outVector);
-    PS_CHECK_DIMEN_AND_TYPE(inVector, PS_DIMEN_VECTOR, outVector);
-    PS_VECTOR_CHECK_NULL(inPerm, outVector);
-    psVectorRecycle(outVector, inImage->numRows, inImage->type.type);
+    #define LUSOLVE_CLEANUP {psFree(outVector); return NULL;}
+
+    // Error checks
+    PS_IMAGE_CHECK_NULL_GENERAL(inImage, LUSOLVE_CLEANUP);
+    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, LUSOLVE_CLEANUP);
+    PS_IMAGE_CHECK_EMPTY_GENERAL(inImage, LUSOLVE_CLEANUP);
+    PS_VECTOR_CHECK_NULL_GENERAL(inVector, LUSOLVE_CLEANUP);
+    PS_CHECK_DIMEN_AND_TYPE(inVector, PS_DIMEN_VECTOR, LUSOLVE_CLEANUP);
+    PS_VECTOR_CHECK_NULL_GENERAL(inPerm, LUSOLVE_CLEANUP);
+
+    outVector = psVectorRecycle(outVector, inImage->numRows, inImage->type.type);
+
+    PS_CHECK_POINTERS(outVector, inVector, LUSOLVE_CLEANUP);
+    PS_CHECK_POINTERS(inVector, inPerm, LUSOLVE_CLEANUP);
+    PS_CHECK_POINTERS(outVector, inPerm, LUSOLVE_CLEANUP);
 
     // Initialize data
@@ -296,13 +298,16 @@
     gsl_permutation *perm = NULL;
 
-    // Error checks
-    PS_PTR_CHECK_NULL(det, outImage);
-    PS_CHECK_POINTERS(inImage, outImage, outImage);
-    PS_IMAGE_CHECK_NULL(inImage, outImage);
-    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outImage);
-    PS_IMAGE_CHECK_EMPTY(inImage, outImage);
+    #define INVERT_CLEANUP { psFree(outImage); return NULL; }
+    // Error checks
+    PS_PTR_CHECK_NULL_GENERAL(det, INVERT_CLEANUP);
+    PS_IMAGE_CHECK_NULL_GENERAL(inImage, INVERT_CLEANUP);
+    PS_CHECK_POINTERS(inImage, outImage, INVERT_CLEANUP);
+    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, INVERT_CLEANUP);
+    PS_IMAGE_CHECK_EMPTY_GENERAL(inImage, INVERT_CLEANUP);
+
     outImage = psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type);
-    PS_CHECK_SQUARE(inImage, outImage);
-    PS_CHECK_SQUARE(outImage, outImage);
+
+    PS_CHECK_SQUARE(inImage, INVERT_CLEANUP);
+    PS_CHECK_SQUARE(outImage, INVERT_CLEANUP);
 
     // Initialize data
@@ -341,9 +346,10 @@
     gsl_permutation *perm = NULL;
 
-    // Error checks
-    PS_IMAGE_CHECK_NULL(inImage, NULL);
-    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, NULL);
-    PS_IMAGE_CHECK_EMPTY(inImage, NULL);
-    PS_CHECK_SQUARE(inImage, 0);
+    #define DETERMINANT_EXIT { return NULL; }
+    // Error checks
+    PS_IMAGE_CHECK_NULL_GENERAL(inImage, DETERMINANT_EXIT);
+    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, DETERMINANT_EXIT);
+    PS_IMAGE_CHECK_EMPTY_GENERAL(inImage, DETERMINANT_EXIT);
+    PS_CHECK_SQUARE(inImage, DETERMINANT_EXIT);
 
     // Initialize data
@@ -376,20 +382,21 @@
     gsl_matrix *m3 = NULL;
 
-    // Error checks
-    PS_CHECK_POINTERS(inImage1, outImage, outImage);
-    PS_CHECK_POINTERS(inImage1, inImage2, outImage);
-    PS_IMAGE_CHECK_NULL(inImage1, outImage);
-    PS_CHECK_DIMEN_AND_TYPE(inImage1, PS_DIMEN_IMAGE, outImage);
-    PS_IMAGE_CHECK_EMPTY(inImage1, outImage);
-    PS_IMAGE_CHECK_NULL(inImage2, outImage);
-    PS_CHECK_DIMEN_AND_TYPE(inImage2, PS_DIMEN_IMAGE, outImage);
-    PS_IMAGE_CHECK_EMPTY(inImage2, outImage);
-    PS_CHECK_DIMEN_AND_TYPE(inImage1, PS_DIMEN_IMAGE, outImage);
+    #define MULTIPLY_CLEANUP { psFree(outImage); return NULL; }
+
+    // Error checks
+    PS_IMAGE_CHECK_NULL_GENERAL(inImage1, MULTIPLY_CLEANUP);
+    PS_IMAGE_CHECK_NULL_GENERAL(inImage2, MULTIPLY_CLEANUP);
+    PS_IMAGE_CHECK_EMPTY_GENERAL(inImage1, MULTIPLY_CLEANUP);
+    PS_IMAGE_CHECK_EMPTY_GENERAL(inImage2, MULTIPLY_CLEANUP);
+    PS_CHECK_DIMEN_AND_TYPE(inImage1, PS_DIMEN_IMAGE, MULTIPLY_CLEANUP);
+    PS_CHECK_DIMEN_AND_TYPE(inImage2, PS_DIMEN_IMAGE, MULTIPLY_CLEANUP);
+    PS_CHECK_POINTERS(inImage1, outImage, MULTIPLY_CLEANUP);
+    PS_CHECK_POINTERS(inImage1, inImage2, MULTIPLY_CLEANUP);
 
     outImage = psImageRecycle(outImage, inImage2->numCols, inImage2->numRows, inImage2->type.type);
 
-    PS_CHECK_SQUARE(inImage1, outImage);
-    PS_CHECK_SQUARE(inImage2, outImage);
-    PS_CHECK_SQUARE(outImage, outImage);
+    PS_CHECK_SQUARE(inImage1, MULTIPLY_CLEANUP);
+    PS_CHECK_SQUARE(inImage2, MULTIPLY_CLEANUP);
+    PS_CHECK_SQUARE(outImage, MULTIPLY_CLEANUP);
 
     // Initialize data
@@ -428,10 +435,11 @@
     psS32 numColsOut = 0;
 
-
-    // Error checks
-    PS_CHECK_POINTERS(inImage, outImage, outImage);
-    PS_IMAGE_CHECK_NULL(inImage, outImage);
-    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outImage);
-    PS_IMAGE_CHECK_EMPTY(inImage, outImage);
+    #define TRANSPOSE_CLEANUP { psFree(outImage); return NULL; }
+    // Error checks
+    PS_IMAGE_CHECK_NULL_GENERAL(inImage, TRANSPOSE_CLEANUP);
+    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, TRANSPOSE_CLEANUP);
+    PS_IMAGE_CHECK_EMPTY_GENERAL(inImage, TRANSPOSE_CLEANUP);
+    PS_CHECK_POINTERS(inImage, outImage, TRANSPOSE_CLEANUP);
+
     outImage = psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type);
 
@@ -472,10 +480,10 @@
     gsl_matrix *in = NULL;
 
-
-    // Error checks
-    PS_CHECK_POINTERS(inImage, outImage, outImage);
-    PS_IMAGE_CHECK_NULL(inImage, outImage);
-    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outImage);
-    PS_IMAGE_CHECK_EMPTY(inImage, outImage);
+    #define EIGENVECTORS_CLEANUP { psFree(outImage); return NULL; }
+    // Error checks
+    PS_IMAGE_CHECK_NULL_GENERAL(inImage, EIGENVECTORS_CLEANUP);
+    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, EIGENVECTORS_CLEANUP);
+    PS_IMAGE_CHECK_EMPTY_GENERAL(inImage, EIGENVECTORS_CLEANUP);
+    PS_CHECK_POINTERS(inImage, outImage, EIGENVECTORS_CLEANUP);
 
     outImage = psImageRecycle(outImage, inImage->numCols, inImage->numRows, inImage->type.type);
@@ -494,6 +502,6 @@
 
     // Non-square matrices not allowed
-    PS_CHECK_SQUARE(inImage, outImage);
-    PS_CHECK_SQUARE(outImage, outImage);
+    PS_CHECK_SQUARE(inImage, EIGENVECTORS_CLEANUP);
+    PS_CHECK_SQUARE(outImage, EIGENVECTORS_CLEANUP);
 
     // Calculate Eigenvalues and Eigenvectors...Eigenvalues not currently used
@@ -520,14 +528,14 @@
     // Error checks
     PS_IMAGE_CHECK_NULL_GENERAL(inImage, psMatrixToVector_EXIT);
-    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, outVector);
+    PS_CHECK_DIMEN_AND_TYPE(inImage, PS_DIMEN_IMAGE, psMatrixToVector_EXIT);
     PS_IMAGE_CHECK_EMPTY_GENERAL(inImage, psMatrixToVector_EXIT);
 
     if (inImage->numRows == 1) {
         // Create transposed row vector
-        psVectorRecycle(outVector, inImage->numCols, inImage->type.type);
+        outVector = psVectorRecycle(outVector, inImage->numCols, inImage->type.type);
         outVector->type.dimen = PS_DIMEN_TRANSV;
     } else if (inImage->numCols == 1) {
         // Create non-transposed column vector
-        psVectorRecycle(outVector, inImage->numRows, inImage->type.type);
+        outVector = psVectorRecycle(outVector, inImage->numRows, inImage->type.type);
     } else {
         psError(PS_ERR_BAD_PARAMETER_SIZE, true,
@@ -537,9 +545,7 @@
     }
 
-    PS_VECTOR_CHECK_NULL(outVector, outVector);
-
     // More checks
     if (outVector->type.dimen == PS_DIMEN_VECTOR) {
-        PS_CHECK_DIMEN_AND_TYPE(outVector, PS_DIMEN_VECTOR, outVector);
+        PS_CHECK_DIMEN_AND_TYPE(outVector, PS_DIMEN_VECTOR, psMatrixToVector_EXIT);
 
         if (outVector->n == 0) {
@@ -557,5 +563,5 @@
 
     } else if (outVector->type.dimen == PS_DIMEN_TRANSV) {
-        PS_CHECK_DIMEN_AND_TYPE(outVector, PS_DIMEN_TRANSV, outVector);
+        PS_CHECK_DIMEN_AND_TYPE(outVector, PS_DIMEN_TRANSV, psMatrixToVector_EXIT);
 
         if (outVector->n == 0) {
@@ -582,11 +588,14 @@
     psS32 size = 0;
 
-    // Error checks
-    PS_VECTOR_CHECK_NULL(inVector, outImage);
+    #define VECTORTOMATRIX_CLEANUP {psFree(outImage); return NULL; }
+    // Error checks
+    PS_VECTOR_CHECK_NULL_GENERAL(inVector, VECTORTOMATRIX_CLEANUP);
 
     if (inVector->type.dimen == PS_DIMEN_VECTOR) {
-        PS_CHECK_DIMEN_AND_TYPE(inVector, PS_DIMEN_VECTOR, outImage);
-        PS_VECTOR_CHECK_EMPTY(inVector, outImage);
+        PS_CHECK_DIMEN_AND_TYPE(inVector, PS_DIMEN_VECTOR, VECTORTOMATRIX_CLEANUP);
+        PS_VECTOR_CHECK_EMPTY_GENERAL(inVector, VECTORTOMATRIX_CLEANUP);
+
         outImage = psImageRecycle(outImage, 1, inVector->n, inVector->type.type);
+
         // More checks for PS_DIMEN_VECTOR
         if (outImage->numCols > 1) {
@@ -605,6 +614,6 @@
 
     } else if (inVector->type.dimen == PS_DIMEN_TRANSV) {
-        PS_CHECK_DIMEN_AND_TYPE(inVector, PS_DIMEN_TRANSV, outImage);
-        PS_VECTOR_CHECK_EMPTY(inVector, outImage);
+        PS_CHECK_DIMEN_AND_TYPE(inVector, PS_DIMEN_TRANSV, VECTORTOMATRIX_CLEANUP);
+        PS_VECTOR_CHECK_EMPTY_GENERAL(inVector, VECTORTOMATRIX_CLEANUP);
         outImage = psImageRecycle(outImage, inVector->n, 1, inVector->type.type);
         // More checks for PS_DIMEN_TRANSV
@@ -624,6 +633,6 @@
     }
 
-    PS_IMAGE_CHECK_NULL(outImage, outImage);
-    PS_CHECK_DIMEN_AND_TYPE(outImage, PS_DIMEN_IMAGE, outImage);
+    PS_IMAGE_CHECK_NULL_GENERAL(outImage, VECTORTOMATRIX_CLEANUP);
+    PS_CHECK_DIMEN_AND_TYPE(outImage, PS_DIMEN_IMAGE, VECTORTOMATRIX_CLEANUP);
 
     memcpy(outImage->data.V[0], inVector->data.V, size);
Index: /trunk/psLib/test/dataManip/tst_psMatrix02.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psMatrix02.c	(revision 3312)
+++ /trunk/psLib/test/dataManip/tst_psMatrix02.c	(revision 3313)
@@ -12,6 +12,6 @@
  *  @author  Ross Harman, MHPCC
  *
- *  @version $Revision: 1.5 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2005-02-17 19:26:25 $
+ *  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2005-02-24 00:19:51 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -32,30 +32,66 @@
 
     // Test A - Input pointer same as output pointer
-    printNegativeTestHeader(stdout,"psMatrix", "Input pointer same as output pointer",
-                            "Invalid operation: Pointer to inImage is same as outImage.", 0);
-    psMatrixTranspose(inImage, inImage);
+    printPositiveTestHeader(stdout,"psMatrix", "Input pointer same as output pointer");
+    psMemIncrRefCounter(inImage);
+    if (psMatrixTranspose(inImage, inImage) != NULL) {
+        psError(PS_ERR_UNKNOWN, true,
+                "inImage = outImage didn't results in NULL return");
+        return 1;
+    }
+    if (psMemGetRefCounter(inImage) != 1) {
+        psError(PS_ERR_UNKNOWN, true,
+                "the output image was not freed on an error.");
+        return 2;
+    }
     printFooter(stdout, "psMatrix", "Input pointer same as output pointer", true);
 
     // Test B - Null input psImage
-    printNegativeTestHeader(stdout,"psMatrix", "Null input psImage",
-                            "Invalid operation: inImage or its data is NULL.", 0);
-    psMatrixTranspose(outImage, nullImage);
+    printPositiveTestHeader(stdout,"psMatrix", "Null input psImage");
+    psMemIncrRefCounter(outImage);
+    if (psMatrixTranspose(outImage, nullImage) != NULL) {
+        psError(PS_ERR_UNKNOWN, true,
+                "inImage = outImage didn't results in NULL return");
+        return 3;
+    }
+    if (psMemGetRefCounter(outImage) != 1) {
+        psError(PS_ERR_UNKNOWN, true,
+                "the output image was not freed on an error.");
+        return 4;
+    }
     printFooter(stdout, "psMatrix", "Null input psImage", true);
 
     // Test C - Incorrect type for input pointer
-    printNegativeTestHeader(stdout,"psMatrix", "Incorrect type for input pointer",
-                            "|Invalid operation: inImage not PS_TYPE_F64.", 0);
-    psMatrixTranspose(outImage, badImage1);
+    printPositiveTestHeader(stdout,"psMatrix", "Incorrect type for input pointer");
+    psMemIncrRefCounter(outImage);
+    if (psMatrixTranspose(outImage, badImage1) != NULL) {
+        psError(PS_ERR_UNKNOWN, true,
+                "inImage = outImage didn't results in NULL return");
+        return 5;
+    }
+    if (psMemGetRefCounter(outImage) != 1) {
+        psError(PS_ERR_UNKNOWN, true,
+                "the output image was not freed on an error.");
+        return 6;
+    }
     printFooter(stdout, "psMatrix", "Incorrect type for input pointer", true);
 
     // Test D - Incorrect type for output pointer
-    printNegativeTestHeader(stdout,"psMatrix", "Incorrect type for output pointer",
-                            "Invalid operation: outImage not PS_TYPE_F64.", 0);
-    psMatrixTranspose(badImage1, inImage);
+    printPositiveTestHeader(stdout,"psMatrix", "Incorrect type for output pointer");
+    badImage1 = psMatrixTranspose(badImage1, inImage);
+    if (badImage1 == NULL) {
+        psError(PS_ERR_UNKNOWN, true,
+                "inImage = outImage didn't results in NULL return");
+        return 7;
+    }
+    // check that the type was changed.
+    if (badImage1->type.type != PS_TYPE_F64) {
+        psError(PS_ERR_UNKNOWN, true,
+                "the output image was not freed on an error.");
+        return 8;
+    }
     printFooter(stdout, "psMatrix", "Incorrect type for output pointer", true);
 
     // Test E - Matrix not square for output pointer
-    printNegativeTestHeader(stdout,"psMatrix", "Matrix not square for output pointer",
-                            "Invalid operation: outImage not square array.", 0);
+    printPositiveTestHeader(stdout,"psMatrix", "Matrix not square for output pointer");
     psMatrixTranspose(badImage2, inImage);
     printFooter(stdout, "psMatrix", "Matrix not square for output pointer", true);
Index: /trunk/psLib/test/dataManip/tst_psMatrix03.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psMatrix03.c	(revision 3312)
+++ /trunk/psLib/test/dataManip/tst_psMatrix03.c	(revision 3313)
@@ -14,6 +14,6 @@
  *  @author  Ross Harman, MHPCC
  *
- *  @version $Revision: 1.14 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2005-02-17 19:26:25 $
+ *  @version $Revision: 1.15 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2005-02-24 00:19:51 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -148,5 +148,4 @@
     printFooter(stdout, "psMatrix", "Calculate LU matrix", true);
 
-
     // Test C - Determine solution to matrix equation
     printPositiveTestHeader(stdout, "psMatrix", "Determine solution to matrix equation");
@@ -208,4 +207,5 @@
     psVector *vectorBadOut = (psVector*)psVectorAlloc(3, PS_TYPE_F64);
     psVector *permBad = (psVector*)psVectorAlloc(3, PS_TYPE_F64);
+    imageTest = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64);
     psMatrixLUSolve(vectorBadOut, imageTest, vectorBad, permBad);
     printFooter(stdout, "psMatrix", "Attempt to use null input vector argument", true);
@@ -215,7 +215,20 @@
     printNegativeTestHeader(stdout,"psMatrix", "Attempt to use null LU image argument",
                             "Invalid operation: inImage or its data is NULL.", 0);
+    vectorBadOut = (psVector*)psVectorAlloc(3, PS_TYPE_F64);
     psMatrixLUSolve(vectorBadOut, NULL, vectorBad, permBad);
     printFooter(stdout, "psMatrix", "Attempt to use null LU image argument", true);
 
+    psFree(permBad);
+    psFree(imageTest);
+
+    if( psMemCheckLeaks(0, NULL, stdout, false) ) {
+        psError(PS_ERR_UNKNOWN,true,"Memory leaks detected");
+        return 10;
+    }
+    nBad = psMemCheckCorruption(0);
+    if(nBad) {
+        printf("ERROR: Found %d bad memory blocks\n", nBad);
+    }
+
     return 0;
 }
Index: /trunk/psLib/test/dataManip/tst_psMatrix07.c
===================================================================
--- /trunk/psLib/test/dataManip/tst_psMatrix07.c	(revision 3312)
+++ /trunk/psLib/test/dataManip/tst_psMatrix07.c	(revision 3313)
@@ -16,6 +16,6 @@
  *  @author  Ross Harman, MHPCC
  *
- *  @version $Revision: 1.10 $  $Name: not supported by cvs2svn $
- *  @date  $Date: 2005-02-19 00:43:32 $
+ *  @version $Revision: 1.11 $  $Name: not supported by cvs2svn $
+ *  @date  $Date: 2005-02-24 00:19:51 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -245,10 +245,10 @@
                             "Invalid operation: inVector or its data is NULL.", 0);
     psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
-    if(psVectorToMatrix(m2, NULL) != m2) {
+    if(psVectorToMatrix(m2, NULL) != NULL) {
         psError(PS_ERR_UNKNOWN,true,"Did not return output image");
         return 12;
     }
     psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
-    if(psVectorToMatrix(m2_32, NULL) != m2_32) {
+    if(psVectorToMatrix(m2_32, NULL) != NULL) {
         psError(PS_ERR_UNKNOWN,true,"Did not return output image");
         return 13;
@@ -288,5 +288,4 @@
     psFree(m1);
     psFree(v1);
-    psFree(m2);
     psFree(v2);
     psFree(v3);
@@ -295,5 +294,4 @@
     psFree(m1_32);
     psFree(v1_32);
-    psFree(m2_32);
     psFree(v2_32);
     psFree(v3_32);
Index: /trunk/psLib/test/dataManip/verified/tst_psMatrix02.stdout
===================================================================
--- /trunk/psLib/test/dataManip/verified/tst_psMatrix02.stdout	(revision 3312)
+++ /trunk/psLib/test/dataManip/verified/tst_psMatrix02.stdout	(revision 3313)
@@ -2,7 +2,5 @@
 *             TestFile: tst_psMatrix02.c                                           *
 *            TestPoint: psMatrix{Input pointer same as output pointer}             *
-*             TestType: Negative                                                   *
-*    ExpectedErrorText: Invalid operation: Pointer to inImage is same as outImage. *
-*  ExpectedStatusValue: 0                                                          *
+*             TestType: Positive                                                   *
 \**********************************************************************************/
 
@@ -13,7 +11,5 @@
 *             TestFile: tst_psMatrix02.c                                           *
 *            TestPoint: psMatrix{Null input psImage}                               *
-*             TestType: Negative                                                   *
-*    ExpectedErrorText: Invalid operation: inImage or its data is NULL.            *
-*  ExpectedStatusValue: 0                                                          *
+*             TestType: Positive                                                   *
 \**********************************************************************************/
 
@@ -24,7 +20,5 @@
 *             TestFile: tst_psMatrix02.c                                           *
 *            TestPoint: psMatrix{Incorrect type for input pointer}                 *
-*             TestType: Negative                                                   *
-*    ExpectedErrorText: |Invalid operation: inImage not PS_TYPE_F64.               *
-*  ExpectedStatusValue: 0                                                          *
+*             TestType: Positive                                                   *
 \**********************************************************************************/
 
@@ -35,7 +29,5 @@
 *             TestFile: tst_psMatrix02.c                                           *
 *            TestPoint: psMatrix{Incorrect type for output pointer}                *
-*             TestType: Negative                                                   *
-*    ExpectedErrorText: Invalid operation: outImage not PS_TYPE_F64.               *
-*  ExpectedStatusValue: 0                                                          *
+*             TestType: Positive                                                   *
 \**********************************************************************************/
 
@@ -46,7 +38,5 @@
 *             TestFile: tst_psMatrix02.c                                           *
 *            TestPoint: psMatrix{Matrix not square for output pointer}             *
-*             TestType: Negative                                                   *
-*    ExpectedErrorText: Invalid operation: outImage not square array.              *
-*  ExpectedStatusValue: 0                                                          *
+*             TestType: Positive                                                   *
 \**********************************************************************************/
 
