Index: /branches/eam_branches/ipp-20110505/Ohana/src/relphot/include/relphot.h
===================================================================
--- /branches/eam_branches/ipp-20110505/Ohana/src/relphot/include/relphot.h	(revision 31534)
+++ /branches/eam_branches/ipp-20110505/Ohana/src/relphot/include/relphot.h	(revision 31535)
@@ -140,6 +140,6 @@
 void          dump_grid           PROTO((void)); 
 int           edge_check          PROTO((double *x1, double *y1, double *x2, double *y2));
-void          findImages          PROTO((Catalog *catalog, int Ncatalog));
-int           findMosaics         PROTO((Catalog *catalog, int Ncatalog));
+void          findImages          PROTO((Catalog *catalog, int Ncatalog, int doImageList));
+int           findMosaics         PROTO((Catalog *catalog, int Ncatalog, int doMosaicList));
 
 void set_db (FITS_DB *in);
@@ -150,6 +150,6 @@
 
 void          freeGridBins        PROTO((int Ncatalog));
-void          freeImageBins       PROTO((int Ncatalog));
-void          freeMosaicBins      PROTO((int Ncatalog));
+void          freeImageBins       PROTO((int Ncatalog, int doImageList));
+void          freeMosaicBins      PROTO((int Ncatalog, int doMosaicList));
 void          free_catalogs       PROTO((Catalog *catalog, int Ncatalog));
 int           gcatalog            PROTO((Catalog *catalog, int FINAL));
@@ -165,7 +165,7 @@
 void          initGrid            PROTO((int dX, int dY));
 void          initGridBins        PROTO((Catalog *catalog, int Ncatalog));
-void          initImageBins       PROTO((Catalog *catalog, int Ncatalog));
+void          initImageBins       PROTO((Catalog *catalog, int Ncatalog, int doImageList));
 void          initImages          PROTO((Image *input, off_t *LineNumber, off_t N));
-void          initMosaicBins      PROTO((Catalog *catalog, int Ncatalog));
+void          initMosaicBins      PROTO((Catalog *catalog, int Ncatalog, int doMosaicList));
 void          initMosaicGrid      PROTO((Image *image, off_t Nimage));
 void          initMosaics         PROTO((Image *image, off_t Nimage));
@@ -180,6 +180,6 @@
 int           main                PROTO((int argc, char **argv));
 void          mark_images         PROTO((Image *image, off_t Nimage, Image *timage, off_t Ntimage));
-void          matchImage          PROTO((Catalog *catalog, off_t meas, int cat));
-void          matchMosaics        PROTO((Catalog *catalog, off_t meas, int cat));
+void          matchImage          PROTO((Catalog *catalog, off_t meas, int cat, int doImageList));
+void          matchMosaics        PROTO((Catalog *catalog, off_t meas, int cat, int doMosaicList));
 double        opening_angle       PROTO((double x1, double y1, double x2, double y2, double x3, double y3));
 void          plot_chisq          PROTO((Catalog *catalog, int Ncatalog));
Index: /branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/ImageOps.c
===================================================================
--- /branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/ImageOps.c	(revision 31534)
+++ /branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/ImageOps.c	(revision 31535)
@@ -69,5 +69,5 @@
 }
 
-void initImageBins (Catalog *catalog, int Ncatalog) {
+void initImageBins (Catalog *catalog, int Ncatalog, int doImageList) {
 
   off_t i, j;
@@ -79,18 +79,20 @@
   }
 
-  ALLOCATE (Nlist, off_t, Nimage);
-  ALLOCATE (NLIST, off_t, Nimage);
-  ALLOCATE (clist, off_t *, Nimage);
-  ALLOCATE (mlist, off_t *, Nimage);
-
-  for (i = 0; i < Nimage; i++) {
-    Nlist[i] = 0;
-    NLIST[i] = 100;
-    ALLOCATE (clist[i], off_t, NLIST[i]);
-    ALLOCATE (mlist[i], off_t, NLIST[i]);
-  }
-}
-
-void freeImageBins (int Ncatalog) {
+  if (doImageList) {
+    ALLOCATE (Nlist, off_t, Nimage);
+    ALLOCATE (NLIST, off_t, Nimage);
+    ALLOCATE (clist, off_t *, Nimage);
+    ALLOCATE (mlist, off_t *, Nimage);
+
+    for (i = 0; i < Nimage; i++) {
+      Nlist[i] = 0;
+      NLIST[i] = 100;
+      ALLOCATE (clist[i], off_t, NLIST[i]);
+      ALLOCATE (mlist[i], off_t, NLIST[i]);
+    }
+  }
+}
+
+void freeImageBins (int Ncatalog, int doImageList) {
 
   off_t i;
@@ -100,16 +102,19 @@
   }
   free (bin);
-  for (i = 0; i < Nimage; i++) {
-    free (clist[i]);
-    free (mlist[i]);
-  }
-  free (clist);
-  free (mlist);
-  free (Nlist);
-  free (NLIST);
+
+  if (doImageList) {
+    for (i = 0; i < Nimage; i++) {
+      free (clist[i]);
+      free (mlist[i]);
+    }
+    free (clist);
+    free (mlist);
+    free (Nlist);
+    free (NLIST);
+  }
 }
 
 /* select all image equivalent to the active photcode set */
-void findImages (Catalog *catalog, int Ncatalog) {
+void findImages (Catalog *catalog, int Ncatalog, int doImageList) {
 
   off_t j;
@@ -125,5 +130,5 @@
       }
       if (!found) continue; 
-      matchImage (catalog, j, i);
+      matchImage (catalog, j, i, doImageList);
       Nmatch ++;
     }
@@ -181,5 +186,5 @@
 }
 
-void matchImage (Catalog *catalog, off_t meas, int cat) {
+void matchImage (Catalog *catalog, off_t meas, int cat, int doImageList) {
 
   off_t idx, ID;
@@ -207,16 +212,18 @@
   bin[cat][meas] = idx;
 
-  // index for image, Nentry -> catalog
-  clist[idx][Nlist[idx]] = cat;
-
-  // index for image, Nentry -> measure
-  mlist[idx][Nlist[idx]] = meas;
-  Nlist[idx] ++;
-
-  if (Nlist[idx] == NLIST[idx]) {
-    NLIST[idx] += 100;
-    REALLOCATE (clist[idx], off_t, NLIST[idx]);
-    REALLOCATE (mlist[idx], off_t, NLIST[idx]);
-  }	
+  if (doImageList) {
+    // index for image, Nentry -> catalog
+    clist[idx][Nlist[idx]] = cat;
+
+    // index for image, Nentry -> measure
+    mlist[idx][Nlist[idx]] = meas;
+    Nlist[idx] ++;
+
+    if (Nlist[idx] == NLIST[idx]) {
+      NLIST[idx] += 100;
+      REALLOCATE (clist[idx], off_t, NLIST[idx]);
+      REALLOCATE (mlist[idx], off_t, NLIST[idx]);
+    }	
+  }
 
   return;
Index: /branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/MosaicOps.c
===================================================================
--- /branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/MosaicOps.c	(revision 31534)
+++ /branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/MosaicOps.c	(revision 31535)
@@ -211,5 +211,5 @@
 }
 
-void initMosaicBins (Catalog *catalog, int Ncatalog) {
+void initMosaicBins (Catalog *catalog, int Ncatalog, int doMosaicList) {
 
   off_t i, j;
@@ -224,19 +224,21 @@
   }
 
-  /* mosaic -> measure */
-  ALLOCATE (Nlist, off_t,   Nmosaic);
-  ALLOCATE (NLIST, off_t,   Nmosaic);
-  ALLOCATE (clist, int *,   Nmosaic);
-  ALLOCATE (mlist, off_t *, Nmosaic);
-
-  for (i = 0; i < Nmosaic; i++) {
-    Nlist[i] = 0;
-    NLIST[i] = 100;
-    ALLOCATE (clist[i], int,   NLIST[i]);
-    ALLOCATE (mlist[i], off_t, NLIST[i]);
-  }
-}
-
-void freeMosaicBins (int Ncatalog) {
+  if (doMosaicList) {
+    /* mosaic -> measure */
+    ALLOCATE (Nlist, off_t,   Nmosaic);
+    ALLOCATE (NLIST, off_t,   Nmosaic);
+    ALLOCATE (clist, int *,   Nmosaic);
+    ALLOCATE (mlist, off_t *, Nmosaic);
+
+    for (i = 0; i < Nmosaic; i++) {
+      Nlist[i] = 0;
+      NLIST[i] = 100;
+      ALLOCATE (clist[i], int,   NLIST[i]);
+      ALLOCATE (mlist[i], off_t, NLIST[i]);
+    }
+  }
+}
+
+void freeMosaicBins (int Ncatalog, int doMosaicList) {
 
   off_t i;
@@ -250,16 +252,18 @@
   free (bin);
 
-  /* mosaic -> measure */
-  for (i = 0; i < Nmosaic; i++) {
-    free (clist[i]);
-    free (mlist[i]);
-  }
-  free (Nlist);
-  free (NLIST);
-  free (clist);
-  free (mlist);
-}
-
-int findMosaics (Catalog *catalog, int Ncatalog) {
+  if (doMosaicList) {
+    /* mosaic -> measure */
+    for (i = 0; i < Nmosaic; i++) {
+      free (clist[i]);
+      free (mlist[i]);
+    }
+    free (Nlist);
+    free (NLIST);
+    free (clist);
+    free (mlist);
+  }
+}
+
+int findMosaics (Catalog *catalog, int Ncatalog, int doMosaicList) {
   
   int i, ecode, found, Ns;
@@ -281,5 +285,5 @@
       }
       if (!found) continue;
-      matchMosaics (catalog, j, i);
+      matchMosaics (catalog, j, i, doMosaicList);
       Nmatch ++;
     }
@@ -289,5 +293,5 @@
 }
 
-void matchMosaics (Catalog *catalog, off_t meas, int cat) {
+void matchMosaics (Catalog *catalog, off_t meas, int cat, int doMosaicList) {
 
   off_t idx, ID, mosID;
@@ -322,13 +326,15 @@
   bin[cat][meas] = mosID;
 
-  clist[mosID][Nlist[mosID]] = cat;
-  mlist[mosID][Nlist[mosID]] = meas;
-  Nlist[mosID] ++;
+  if (doMosaicList) {
+    clist[mosID][Nlist[mosID]] = cat;
+    mlist[mosID][Nlist[mosID]] = meas;
+    Nlist[mosID] ++;
     
-  if (Nlist[mosID] == NLIST[mosID]) {
-    NLIST[mosID] += 100;
-    REALLOCATE (clist[mosID], int,   NLIST[mosID]);
-    REALLOCATE (mlist[mosID], off_t, NLIST[mosID]);
-  }	
+    if (Nlist[mosID] == NLIST[mosID]) {
+      NLIST[mosID] += 100;
+      REALLOCATE (clist[mosID], int,   NLIST[mosID]);
+      REALLOCATE (mlist[mosID], off_t, NLIST[mosID]);
+    }	
+  }
   return;
 }
Index: /branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/bcatalog.c
===================================================================
--- /branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/bcatalog.c	(revision 31534)
+++ /branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/bcatalog.c	(revision 31535)
@@ -340,7 +340,7 @@
 int free_tiny_values (Catalog *catalog) {
 
-  free (catalog[0].averageT);
-  free (catalog[0].measureT);
-  return (TRUE);
-}
-
+  if (catalog[0].averageT) free (catalog[0].averageT);
+  if (catalog[0].measureT) free (catalog[0].measureT);
+  return (TRUE);
+}
+
Index: /branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/reload_catalogs.c
===================================================================
--- /branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/reload_catalogs.c	(revision 31534)
+++ /branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/reload_catalogs.c	(revision 31535)
@@ -60,11 +60,11 @@
     TIMESTAMP(time3a);
 
-    initImageBins  (&catalog, 1);
-    initMosaicBins (&catalog, 1);
+    initImageBins  (&catalog, 1, FALSE);
+    initMosaicBins (&catalog, 1, FALSE);
     initGridBins   (&catalog, 1); 
     TIMESTAMP(time3b);
 
-    findImages (&catalog, 1);  // FX
-    findMosaics (&catalog, 1); // 
+    findImages (&catalog, 1, FALSE);
+    findMosaics (&catalog, 1, FALSE);
     TIMESTAMP(time4);
 
@@ -79,6 +79,6 @@
     TIMESTAMP(time6);
 
-    freeImageBins (1);
-    freeMosaicBins (1);
+    freeImageBins (1, FALSE);
+    freeMosaicBins (1, FALSE);
     freeGridBins (1);
     TIMESTAMP(time7);
Index: /branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/relphot.c
===================================================================
--- /branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/relphot.c	(revision 31534)
+++ /branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/relphot.c	(revision 31535)
@@ -66,15 +66,15 @@
 
   /* match measurements with images, mosaics */
-  initImageBins  (catalog, Ncatalog);
+  initImageBins  (catalog, Ncatalog, TRUE);
   MARKTIME("-- make image bins: %f sec\n", dtime);
 
-  initMosaicBins (catalog, Ncatalog);
+  initMosaicBins (catalog, Ncatalog, TRUE);
   initGridBins   (catalog, Ncatalog);
   initMrel (catalog, Ncatalog);
 
-  findImages (catalog, Ncatalog);
+  findImages (catalog, Ncatalog, TRUE);
   MARKTIME("-- set up image indexes: %f sec\n", dtime);
 
-  findMosaics (catalog, Ncatalog);  /* also sets Grid values */
+  findMosaics (catalog, Ncatalog, TRUE);  /* also sets Grid values */
   MARKTIME("-- set up mosaic indexes: %f sec\n", dtime);
 
@@ -220,6 +220,6 @@
     dvo_catalog_free (&catalog[i]);
   }
-  freeImageBins (Ncatalog);
-  freeMosaicBins (Ncatalog);
+  freeImageBins (Ncatalog, TRUE);
+  freeMosaicBins (Ncatalog, TRUE);
   freeGridBins (Ncatalog);
 
