Index: trunk/psModules/src/camera/pmFPA.c
===================================================================
--- trunk/psModules/src/camera/pmFPA.c	(revision 7173)
+++ trunk/psModules/src/camera/pmFPA.c	(revision 7274)
@@ -12,6 +12,6 @@
 * XXX: Should we implement non-linear cell->chip transforms?
 *
-*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-05-23 01:09:48 $
+*  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-06-01 22:43:26 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -136,4 +136,6 @@
 void pmCellFreeReadouts(pmCell *cell)
 {
+    PS_ASSERT_PTR_NON_NULL(cell,);
+
     //
     // Set the parent to NULL in all cell->readouts before psFree(cell->readouts)
@@ -156,4 +158,6 @@
 void pmChipFreeCells(pmChip *chip)
 {
+    PS_ASSERT_PTR_NON_NULL(chip,);
+
     //
     // Set the parent to NULL in all chip->cells before psFree(chip->cells)
@@ -175,4 +179,6 @@
 void pmCellFreeData(pmCell *cell)
 {
+    PS_ASSERT_PTR_NON_NULL(cell,);
+
     pmCellFreeReadouts(cell);
     if (cell->hdu) {
@@ -184,4 +190,6 @@
 void pmChipFreeData(pmChip *chip)
 {
+    PS_ASSERT_PTR_NON_NULL(chip,);
+
     for (int i = 0; i < chip->cells->n; i++) {
         pmCellFreeData(chip->cells->data[i]);
@@ -195,4 +203,6 @@
 void pmFPAFreeData(pmFPA *fpa)
 {
+    PS_ASSERT_PTR_NON_NULL(fpa,);
+
     for (int i = 0; i < fpa->chips->n; i++) {
         pmChipFreeData(fpa->chips->data[i]);
@@ -206,5 +216,5 @@
 pmReadout *pmReadoutAlloc(pmCell *cell)
 {
-    pmReadout *tmpReadout = (pmReadout *) psAlloc(sizeof(pmReadout));
+    pmReadout *tmpReadout = (pmReadout *)psAlloc(sizeof(pmReadout));
     psMemSetDeallocator(tmpReadout, (psFreeFunc) readoutFree);
 
@@ -215,5 +225,5 @@
     tmpReadout->analysis = psMetadataAlloc();
     tmpReadout->parent = cell;
-    if (cell != NULL) {
+    if (cell) {
         cell->readouts = psArrayAdd(cell->readouts, 1, (psPtr) tmpReadout);
     }
@@ -241,5 +251,5 @@
     tmpCell->readouts = psArrayAlloc(0);
     tmpCell->parent = chip;
-    if (chip != NULL) {
+    if (chip) {
         chip->cells = psArrayAdd(chip->cells, 1, (psPtr) tmpCell);
     }
@@ -256,5 +266,5 @@
     pmConceptsBlankCell(tmpCell);
 
-    return(tmpCell);
+    return tmpCell;
 }
 
@@ -263,20 +273,20 @@
     const char *name)
 {
-    pmChip *tmpChip = (pmChip *) psAlloc(sizeof(pmChip));
+    pmChip *tmpChip = (pmChip*)psAlloc(sizeof(pmChip));
     psMemSetDeallocator(tmpChip, (psFreeFunc) chipFree);
 
-    # if FPA_ASTROM
+    #if FPA_ASTROM
 
     tmpChip->col0 = 0;
-tmpChip->row0 = 0;
-tmpChip->toFPA = NULL;
-tmpChip->fromFPA = NULL;
-# endif
-
-tmpChip->analysis = psMetadataAlloc();
+    tmpChip->row0 = 0;
+    tmpChip->toFPA = NULL;
+    tmpChip->fromFPA = NULL;
+    # endif
+
+    tmpChip->analysis = psMetadataAlloc();
     tmpChip->cells = psArrayAlloc(0);
     tmpChip->parent = fpa;
-    if (fpa != NULL) {
-        psArrayAdd(fpa->chips, 1, (psPtr) tmpChip);
+    if (fpa) {
+        psArrayAdd(fpa->chips, 1, (psPtr)tmpChip);
     }
     tmpChip->hdu = NULL;
@@ -292,5 +302,5 @@
     }
     pmConceptsBlankChip(tmpChip);
-    return(tmpChip);
+    return tmpChip;
 }
 
@@ -300,13 +310,13 @@
     psMemSetDeallocator(tmpFPA, (psFreeFunc) FPAFree);
 
-    # if FPA_ASTROM
+    #if FPA_ASTROM
 
     tmpFPA->fromTangentPlane = NULL;
-tmpFPA->toTangentPlane = NULL;
-tmpFPA->projection = NULL;
-# endif
-
-tmpFPA->analysis = NULL;
-tmpFPA->camera = psMemIncrRefCounter((psPtr)camera);
+    tmpFPA->toTangentPlane = NULL;
+    tmpFPA->projection = NULL;
+    # endif
+
+    tmpFPA->analysis = NULL;
+    tmpFPA->camera = psMemIncrRefCounter((psPtr)camera);
     tmpFPA->chips = psArrayAlloc(0);
     tmpFPA->hdu = NULL;
@@ -316,17 +326,17 @@
     pmConceptsBlankFPA(tmpFPA);
 
-    return(tmpFPA);
-}
-
-static psBool cellCheckParents(pmCell *cell)
-{
-    if (!cell) {
-        return(true);
-    }
-    psBool flag = true;
-
-    for (psS32 i = 0 ; i < cell->readouts->n ; i++) {
+    return tmpFPA;
+}
+
+static bool cellCheckParents(pmCell *cell)
+{
+    PS_ASSERT_PTR_NON_NULL(cell, true);
+
+    bool flag = true;
+    for (long i = 0; i < cell->readouts->n ; i++) {
         pmReadout *tmpReadout = (pmReadout *) cell->readouts->data[i];
-        PS_ASSERT_PTR_NON_NULL(tmpReadout, false);
+        if (!tmpReadout) {
+            continue;
+        }
         if (tmpReadout->parent != cell) {
             tmpReadout->parent = cell;
@@ -334,17 +344,17 @@
         }
     }
-    return(flag);
-}
-
-static psBool chipCheckParents(pmChip *chip)
-{
-    if (!chip) {
-        return(true);
-    }
-    psBool flag = true;
-
-    for (psS32 i = 0 ; i < chip->cells->n ; i++) {
+    return flag;
+}
+
+static bool chipCheckParents(pmChip *chip)
+{
+    PS_ASSERT_PTR_NON_NULL(chip, true);
+
+    bool flag = true;
+    for (long i = 0; i < chip->cells->n ; i++) {
         pmCell *tmpCell = (pmCell *) chip->cells->data[i];
-        PS_ASSERT_PTR_NON_NULL(tmpCell, false);
+        if (!tmpCell) {
+            continue;
+        }
         if (tmpCell->parent != chip) {
             tmpCell->parent = chip;
@@ -354,17 +364,17 @@
         flag &= cellCheckParents(tmpCell);
     }
-    return(flag);
+    return flag;
 }
 
 psBool pmFPACheckParents(pmFPA *fpa)
 {
-    if (!fpa) {
-        return(true);
-    }
-    psBool flag = true;
-
-    for (psS32 i = 0 ; i < fpa->chips->n ; i++) {
+    PS_ASSERT_PTR_NON_NULL(fpa, true);
+
+    bool flag = true;
+    for (long i = 0; i < fpa->chips->n ; i++) {
         pmChip *tmpChip = (pmChip *) fpa->chips->data[i];
-        PS_ASSERT_PTR_NON_NULL(tmpChip, false);
+        if (!tmpChip) {
+            continue;
+        }
         if (tmpChip->parent != fpa) {
             tmpChip->parent = fpa;
@@ -374,10 +384,11 @@
         flag &= chipCheckParents(tmpChip);
     }
-    return(flag);
+    return flag;
 }
 
 /** functions to turn on/off the file_exists flag **/
-bool pmFPASetFileStatus (pmFPA *fpa, bool status)
-{
+bool pmFPASetFileStatus(pmFPA *fpa, bool status)
+{
+    PS_ASSERT_PTR_NON_NULL(fpa, false);
 
     for (int i = 0; i < fpa->chips->n; i++) {
@@ -388,6 +399,7 @@
 }
 
-bool pmChipSetFileStatus (pmChip *chip, bool status)
-{
+bool pmChipSetFileStatus pmChip *chip, bool status)
+{
+    PS_ASSERT_PTR_NON_NULL(chip, false);
 
     chip->file_exists = status;
@@ -399,6 +411,7 @@
 }
 
-bool pmCellSetFileStatus (pmCell *cell, bool status)
-{
+bool pmCellSetFileStatus(pmCell *cell, bool status)
+{
+    PS_ASSERT_PTR_NON_NULL(cell, false);
 
     cell->file_exists = status;
@@ -411,6 +424,7 @@
 
 /** functions to turn on/off the data_exists flag **/
-bool pmFPASetDataStatus (pmFPA *fpa, bool status)
-{
+bool pmFPASetDataStatus(pmFPA *fpa, bool status)
+{
+    PS_ASSERT_PTR_NON_NULL(fpa, false);
 
     for (int i = 0; i < fpa->chips->n; i++) {
@@ -421,6 +435,7 @@
 }
 
-bool pmChipSetDataStatus (pmChip *chip, bool status)
-{
+bool pmChipSetDataStatus(pmChip *chip, bool status)
+{
+    PS_ASSERT_PTR_NON_NULL(chip, false);
 
     chip->data_exists = status;
@@ -434,4 +449,5 @@
 bool pmCellSetDataStatus (pmCell *cell, bool status)
 {
+    PS_ASSERT_PTR_NON_NULL(cell, false);
 
     cell->data_exists = status;
@@ -507,5 +523,5 @@
 bool pmChipSelectCell(pmChip *chip, int cellNum, bool exclusive)
 {
-    assert(chip);
+    PS_ASSERT_PTR_NON_NULL(chip, false);
 
     psArray *cells = chip->cells;       // Component cells
@@ -548,5 +564,5 @@
     int chipNum)
 {
-    PS_ASSERT_PTR_NON_NULL(fpa, false);
+    PS_ASSERT_PTR_NON_NULL(fpa, -1);
 
     psArray *chips = fpa->chips;        // Component chips
@@ -580,5 +596,5 @@
                      )
 {
-    assert(chip);
+    PS_ASSERT_PTR_NON_NULL(chip, -1);
 
     psArray *cells = chip->cells;       // The component cells
