Index: /branches/eam_branches/ipp-20140610/Ohana/src/dvomerge/src/merge_catalogs_old.c
===================================================================
--- /branches/eam_branches/ipp-20140610/Ohana/src/dvomerge/src/merge_catalogs_old.c	(revision 37008)
+++ /branches/eam_branches/ipp-20140610/Ohana/src/dvomerge/src/merge_catalogs_old.c	(revision 37009)
@@ -31,5 +31,9 @@
   ALLOCATE (Y1, double, input[0].Naverage);
   ALLOCATE (N1, off_t,  input[0].Naverage);
-  ALLOCATE (input[0].found, off_t, input[0].Naverage);
+  if (!input[0].found_t) {
+    ALLOCATE (input[0].found_t, off_t, input[0].Naverage);
+  } else {
+    REALLOCATE (input[0].found_t, off_t, input[0].Naverage);
+  }
 
   /** allocate local arrays (catalog) **/
@@ -38,5 +42,9 @@
   ALLOCATE (Y2, double, NAVE);
   ALLOCATE (N2, off_t,    NAVE);
-  ALLOCATE (output[0].found, off_t, NAVE);
+  if (!output[0].found_t) {
+    ALLOCATE (output[0].found_t, off_t, NAVE);
+  } else {
+    REALLOCATE (output[0].found_t, off_t, NAVE);
+  }
   /* for secfilt j and star i, secfilt[i*Nsecfilt+j] */
 
@@ -78,10 +86,8 @@
     N1[Nstars] = i;
     Nstars ++;
-    input[0].found[i] = -1;
+    input[0].found_t[i] = -1;
   }
   if (Nstars < 1) {
     if (VERBOSE) fprintf (stderr, "skipping %s, no overlapping stars\n", output[0].filename);
-    free (output[0].found);
-    free (input[0].found);
     free (X1);
     free (Y1);
@@ -97,5 +103,5 @@
   for (i = 0; i < Nave; i++) {
     RD_to_XY (&X2[i], &Y2[i], output[0].average[i].R, output[0].average[i].D, &tcoords);
-    output[0].found[i] = -1;
+    output[0].found_t[i] = -1;
     N2[i] = i;
   }
@@ -187,5 +193,5 @@
 	int Mout = output[0].average[n].measureOffset;  
 	if (replace_match(&output[0].average[n], &output[0].measure[Mout], &input[0].average[N], &input[0].measure[offset])) {
-	  input[0].found[N] = Mout;
+	  input[0].found_t[N] = Mout;
 	  continue;
 	}
@@ -237,5 +243,5 @@
         }
       }
-      input[0].found[N] = Nmeas;
+      input[0].found_t[N] = Nmeas;
       output[0].average[n].Nmeasure ++;
       Nmeas ++;
@@ -266,5 +272,5 @@
     /* Nm is updated, but not written out in -update mode (for existing entries)
        Nm is recalculated in build_meas_links if loaded table is not sorted */
-    output[0].found[n] = Nmeas;
+    output[0].found_t[n] = Nmeas;
     i++;
   }
@@ -288,5 +294,5 @@
     }
 
-    if (input[0].found[N] >= 0) continue;
+    if (input[0].found_t[N] >= 0) continue;
     if (!IN_REGION (input[0].average[N].R, input[0].average[N].D)) continue;
 
@@ -341,5 +347,5 @@
 
       /* we set next[Nmeas] to -1 here, and update correctly below */
-      input[0].found[N] = Nmeas;
+      input[0].found_t[N] = Nmeas;
       next_meas[Nmeas] = -1;
       Nmeas ++;
@@ -367,8 +373,8 @@
   /* note stars which have been found in this catalog */
   for (i = 0; i < input[0].Naverage; i++) {
-    if (input[0].found[i] > -1) {
-      input[0].found[i] = -2;
+    if (input[0].found_t[i] > -1) {
+      input[0].found_t[i] = -2;
     } else {
-      input[0].found[i] = -3;
+      input[0].found_t[i] = -3;
     }
   }
@@ -383,9 +389,7 @@
   free (next_meas);
 
-  free (output[0].found);
   free (X2);
   free (Y2);
   free (N2);
-  free (input[0].found);
   free (X1);
   free (Y1);
@@ -404,5 +408,5 @@
    images have boundaries which are lines in pixels coords, but curve in RA and DEC
    
-   output[0].found[Ncat] but stars[Nstar].found
+   output[0].found_t[Ncat] but stars[Nstar].found
    
 */
