Index: trunk/psLib/src/astronomy/psAstrometry.c
===================================================================
--- trunk/psLib/src/astronomy/psAstrometry.c	(revision 1967)
+++ trunk/psLib/src/astronomy/psAstrometry.c	(revision 1981)
@@ -1,53 +1,28 @@
 /** @file  psAstrometry.c
-*
-*  @brief This file defines the basic types for astronomical coordinate
-*  transformation
-*
-*  @ingroup AstroImage
-*
-*  @author George Gusciora, MHPCC
-*
-*  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-10-06 00:44:16 $
-*
-*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
-*/
+ *
+ *  @brief This file defines the basic types for astronomical coordinate
+ *  transformation
+ *
+ *  @ingroup AstroImage
+ *
+ *  @author George Gusciora, MHPCC
+ *
+ *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-10-06 21:30:14 $
+ *
+ *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
+ */
+
 /******************************************************************************/
 /*  INCLUDE FILES                                                             */
 /******************************************************************************/
-#include "slalib.h"
-
-#include<math.h>
+#include <string.h>
+#include <math.h>
+
 #include "psFunctions.h"
 #include "psAstrometry.h"
 #include "psMemory.h"
 #include "psAbort.h"
-/******************************************************************************/
-/*  DEFINE STATEMENTS                                                         */
-/******************************************************************************/
-
-// None
-
-/******************************************************************************/
-/*  TYPE DEFINITIONS                                                          */
-/******************************************************************************/
-
-// None
-
-/*****************************************************************************/
-/*  GLOBAL VARIABLES                                                         */
-/*****************************************************************************/
-
-// None
-
-/*****************************************************************************/
-/*  FILE STATIC VARIABLES                                                    */
-/*****************************************************************************/
-
-// None
-
-/*****************************************************************************/
-/*  FUNCTION IMPLEMENTATION - LOCAL                                          */
-/*****************************************************************************/
+#include "slalib.h"
 
 /*****************************************************************************
@@ -204,4 +179,27 @@
 }
 
+static void observatoryFree(psObservatory* obs)
+{
+    if (obs != NULL) {
+        psFree((void*)obs->name);
+    }
+}
+
+static void fixedPatternFree(psFixedPattern* fp)
+{
+    if (fp != NULL) {
+        for (int i = 0; i < fp->nX; i++) {
+            psFree(fp->x[i]);
+        }
+
+        for (int j = 0; j < fp->nY; j++) {
+            psFree(fp->y[j]);
+        }
+
+        psFree(fp->x);
+        psFree(fp->y);
+    }
+}
+
 /*****************************************************************************/
 /* FUNCTION IMPLEMENTATION - PUBLIC                                          */
@@ -213,7 +211,6 @@
  * XXX: Verify that you interpreted the SDR correctly.
  *
- * XXX: Must add memory deallocater.
  */
-psFixedPattern *psFixedPatternAlloc(double x0,
+psFixedPattern* psFixedPatternAlloc(double x0,
                                     double y0,
                                     double xScale,
@@ -227,6 +224,6 @@
 
     tmp = (psFixedPattern *) psAlloc(sizeof(psFixedPattern));
-    tmp->nX = x->numRows * x->numCols;
-    tmp->nY = y->numRows * y->numCols;
+    tmp->nX = x->numCols;
+    tmp->nY = y->numRows;
     tmp->x0 = x0;
     tmp->y0 = y0;
@@ -252,4 +249,7 @@
         }
     }
+
+    p_psMemSetDeallocator(tmp,(psFreeFcn)fixedPatternFree);
+
     return(tmp);
 }
@@ -279,7 +279,29 @@
 }
 
-/*
- * psFPA constructor
- */
+psObservatory* psObservatoryAlloc(const char* name,
+                                  double latitude,
+                                  double longitude,
+                                  double height,
+                                  double tlr)
+{
+    psObservatory* obs = psAlloc(sizeof(obs));
+
+    if (obs->name == NULL) {
+        obs->name = NULL;
+    } else {
+        obs->name = psAlloc(strlen(name)+1);
+        strcpy((char*)obs->name, name);
+    }
+
+    *(double *)&obs->latitude = latitude;
+    *(double *)&obs->longitude = longitude;
+    *(double *)&obs->height = height;
+    *(double *)&obs->tlr = tlr;
+
+    p_psMemSetDeallocator(obs,(psFreeFcn)observatoryFree);
+
+    return obs;
+}
+
 psFPA* psFPAAlloc(int nChips,
                   const psExposure* exp)
