Index: trunk/psLib/src/fits/psFitsTable.c
===================================================================
--- trunk/psLib/src/fits/psFitsTable.c	(revision 12549)
+++ trunk/psLib/src/fits/psFitsTable.c	(revision 15179)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-03-22 21:40:47 $
+ *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-10-03 21:27:21 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -38,13 +38,10 @@
                                int row)
 {
+    PS_ASSERT_FITS_NON_NULL(fits, NULL);
+    PS_ASSERT_INT_NONNEGATIVE(row, NULL);
+
     long numRows;
     int numCols;
     int status = 0;
-
-    if (fits == NULL) {
-        psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                _("The input psFits object can not NULL."));
-        return NULL;
-    }
 
     // check to see if we even are positioned on a table HDU
@@ -185,12 +182,9 @@
                                const char* colname)
 {
+    PS_ASSERT_FITS_NON_NULL(fits, NULL);
+    PS_ASSERT_STRING_NON_EMPTY(colname, NULL);
+
     int colnum = 0;
     int status = 0;
-
-    if (fits == NULL) {
-        psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                _("The input psFits object can not NULL."));
-        return NULL;
-    }
 
     // check to see if we even are positioned on a table HDU
@@ -266,12 +260,9 @@
                                    const char* colname)
 {
+    PS_ASSERT_FITS_NON_NULL(fits, NULL);
+    PS_ASSERT_STRING_NON_EMPTY(colname, NULL);
+
     int status = 0;
     int colnum = 0;
-
-    if (fits == NULL) {
-        psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                _("The input psFits object can not NULL."));
-        return NULL;
-    }
 
     // check to see if we even are positioned on a table HDU
@@ -348,11 +339,7 @@
 psArray* psFitsReadTable(const psFits* fits)
 {
+    PS_ASSERT_FITS_NON_NULL(fits, NULL);
+
     int status = 0;
-
-    if (fits == NULL) {
-        psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                _("The input psFits object can not NULL."));
-        return NULL;
-    }
 
     // check to see if we even are positioned on a table HDU
@@ -400,5 +387,9 @@
                       const char *extname)
 {
-    psFitsMoveLast(fits);
+    PS_ASSERT_FITS_NON_NULL(fits, false);
+    if (!psFitsMoveLast(fits)) {
+        psError(PS_ERR_UNKNOWN, false, "Unable to move to last extension to write table");
+        return false;
+    }
     return psFitsInsertTable(fits, header, table, extname, true);
 }
@@ -460,11 +451,9 @@
 // Column specification
 // Included here, because there's no need for the user to have access to it
-typedef struct
-{
+typedef struct {
     psDataType type;                    // psLib type (e.g., PS_DATA_STRING or PS_TYPE_F32)
     size_t size;                        // Size (number of repeats)
     psElemType vectorType;              // psLib type of vectors
-}
-colSpec;
+} colSpec;
 
 
@@ -475,8 +464,8 @@
                        bool after)
 {
+    PS_ASSERT_FITS_NON_NULL(fits, false);
+    PS_ASSERT_ARRAY_NON_NULL(table, false);
+
     int status = 0;
-
-    PS_ASSERT_PTR_NON_NULL(fits, false);
-    PS_ASSERT_ARRAY_NON_NULL(table, false);
 
     long numRows = table->n;
@@ -614,5 +603,6 @@
         char fitsErr[MAX_STRING_LENGTH];
         fits_get_errstatus(status, fitsErr);
-        psError(PS_ERR_LOCATION_INVALID, true, "Unable to create FITS table with %ld columns and %ld rows: %s",
+        psError(PS_ERR_LOCATION_INVALID, true,
+                "Unable to create FITS table with %ld columns and %ld rows: %s",
                 numColumns, table->n, fitsErr);
         psFree(colSpecsIter);
@@ -632,9 +622,9 @@
     if (extname && strlen(extname) > 0) {
         if (!psFitsSetExtName(fits, extname)) {
-	    psError(PS_ERR_IO, false, "Unable to write FITS header extension name.\n");
-	    psFree(colSpecsIter);
-	    psFree(colSpecs);
-	    return false;
-	}
+            psError(PS_ERR_IO, false, "Unable to write FITS header extension name.\n");
+            psFree(colSpecsIter);
+            psFree(colSpecs);
+            return false;
+        }
     }
 
@@ -728,17 +718,9 @@
                        int row)
 {
+    PS_ASSERT_FITS_NON_NULL(fits, false);
+    PS_ASSERT_METADATA_NON_NULL(data, false);
+    PS_ASSERT_INT_NONNEGATIVE(row, false);
+
     int status = 0;
-
-    if (fits == NULL) {
-        psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                _("The input psFits object can not NULL."));
-        return false;
-    }
-
-    if (data == NULL) {
-        psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                _("The input psImage was NULL.  Need a non-NULL psImage for operation to be performed."));
-        return false;
-    }
 
     // check to see if we even are positioned on a table HDU
