Index: /branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/dvo_catalog.c
===================================================================
--- /branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/dvo_catalog.c	(revision 38505)
+++ /branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/dvo_catalog.c	(revision 38506)
@@ -85,28 +85,27 @@
 
 // we can return a static string here unless we run multiple outputs threads at once
-static char compress_string[16];
 char *dvo_catalog_compress_string (DVOCatCompress catcompress) {
-
+  char *compress_string = NULL;
   switch (catcompress) {
     case DVO_COMPRESS_NONE:
-      strcpy (compress_string, "NONE");
+      compress_string = strcreate("NONE");
       break;
     case DVO_COMPRESS_AUTO:
-      strcpy (compress_string, "AUTO");
+      compress_string = strcreate("AUTO");
       break;
     case DVO_COMPRESS_GZIP_1:
-      strcpy (compress_string, "GZIP_1");
+      compress_string = strcreate("GZIP_1");
       break;
     case DVO_COMPRESS_GZIP_2:
-      strcpy (compress_string, "GZIP_2");
+      compress_string = strcreate("GZIP_2");
       break;
     case DVO_COMPRESS_NONE_1:
-      strcpy (compress_string, "NONE_1");
+      compress_string = strcreate("NONE_1");
       break;
     case DVO_COMPRESS_NONE_2:
-      strcpy (compress_string, "NONE_2");
+      compress_string = strcreate("NONE_2");
       break;
     case DVO_COMPRESS_RICE_1:
-      strcpy (compress_string, "RICE_1");
+      compress_string = strcreate("RICE_1");
       break;
     default:
@@ -1158,9 +1157,11 @@
     return FALSE;
   }
-      
+  
+  int outStatus = TRUE;
   status = unlink (tmpfilename);
   if (status) {
+    perror ("unlink: ");
     fprintf (stderr, "failed to unlink catalog %s~\n", catalog->filename);
-    return FALSE;
+    outStatus = FALSE;
   }
       
@@ -1168,40 +1169,40 @@
     if (catalog[0].measure_catalog != NULL) {
       if (!dvo_catalog_unlink_backup (catalog[0].measure_catalog, FALSE)) {
-	return FALSE;
+	outStatus = FALSE;
       }
     }
     if (catalog[0].missing_catalog != NULL) {
       if (!dvo_catalog_unlink_backup (catalog[0].missing_catalog, FALSE)) {
-	return FALSE;
+	outStatus = FALSE;
       }
     }
     if (catalog[0].secfilt_catalog != NULL) {
       if (!dvo_catalog_unlink_backup (catalog[0].secfilt_catalog, FALSE)) {
-	return FALSE;
+	outStatus = FALSE;
       }
     }
     if ((catalog[0].lensing_catalog != NULL) && (catalog[0].Nlensing_disk > 0)) {
       if (!dvo_catalog_unlink_backup (catalog[0].lensing_catalog, FALSE)) {
-	return FALSE;
+	outStatus = FALSE;
       }
     }
     if ((catalog[0].lensobj_catalog != NULL) && (catalog[0].Nlensobj_disk > 0)) {
       if (!dvo_catalog_unlink_backup (catalog[0].lensobj_catalog, FALSE)) {
-	return FALSE;
+	outStatus = FALSE;
       }
     }
     if ((catalog[0].starpar_catalog != NULL) && (catalog[0].Nstarpar_disk > 0)) {
       if (!dvo_catalog_unlink_backup (catalog[0].starpar_catalog, FALSE)) {
-	return FALSE;
+	outStatus = FALSE;
       }
     }
     if ((catalog[0].galphot_catalog != NULL) && (catalog[0].Ngalphot_disk > 0)) {
       if (!dvo_catalog_unlink_backup (catalog[0].galphot_catalog, FALSE)) {
-	return FALSE;
-      }
-    }
-  }
-  return TRUE;
-}
-
-
+	outStatus = FALSE;
+      }
+    }
+  }
+  return outStatus;
+}
+
+
Index: /branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/dvo_catalog_split.c
===================================================================
--- /branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/dvo_catalog_split.c	(revision 38505)
+++ /branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/dvo_catalog_split.c	(revision 38506)
@@ -1,4 +1,4 @@
 # include <dvo.h>
-# define OHANA_MEMCHECK 1
+# define OHANA_MEMCHECK 0
 
 // return options: 
@@ -90,7 +90,5 @@
 int dvo_catalog_save_subcat (Catalog *catalog, FTable *ftable, off_t start, off_t Nrows, off_t Ndisk, off_t Ntotal) {
 
-  Matrix matrix;
-  
-  // if (OHANA_MEMCHECK) ohana_memcheck (TRUE);
+  if (OHANA_MEMCHECK) ohana_memcheck (TRUE);
   
   /* rewind file pointers and truncate (file is still open) */
@@ -108,5 +106,7 @@
   off_t fullsize = catalog->header.datasize;
 
+# if (1)
   // write the PHU matrix; this is probably a NOP, do I have to keep it in?
+  Matrix matrix;
   gfits_create_matrix (&catalog->header, &matrix);
   if (!gfits_fwrite_matrix  (catalog->f, &matrix)) {
@@ -117,4 +117,5 @@
   fullsize += matrix.datasize;
   gfits_free_matrix (&matrix);
+# endif
 
   FTable *outtable = ftable;
@@ -128,5 +129,5 @@
   int isCompressed = output_is_compressed (start, Nrows, Ntotal, catalog->catcompress);
 
-  // if (OHANA_MEMCHECK) ohana_memcheck (TRUE);
+  if (OHANA_MEMCHECK) ohana_memcheck (TRUE);
 
   if (isCompressed) {
@@ -136,18 +137,22 @@
     if (!gfits_compress_table (ftable, &cmptable, 1000, compressMode)) {
       fprintf (stderr, "compression failure\n");
+      free (compressMode);
       return (FALSE);
     }
     if (!byteswap_varlength_ftable (&cmpheader, &cmptable)) {
       fprintf (stderr, "failed to swap varlength column\n");
+      free (compressMode);
       return FALSE;
     }
     if (!gfits_modify (cmptable.header, "DVO_CMP", "%s", 1, compressMode)) {
       fprintf (stderr, "can't save compression mode\n");
-      return (FALSE);
-    }
+      free (compressMode);
+      return (FALSE);
+    }
+    free (compressMode);
     outtable = &cmptable;
   }
 
-  // if (OHANA_MEMCHECK) ohana_memcheck (TRUE);
+  if (OHANA_MEMCHECK) ohana_memcheck (TRUE);
 
   // write the table data
@@ -170,5 +175,5 @@
 
   // XXX test of repeated failure
-  {
+  if (0) {
     Matrix myMatrix;
 
@@ -195,5 +200,5 @@
   }
 
-  // if (OHANA_MEMCHECK) ohana_memcheck (TRUE);
+  if (OHANA_MEMCHECK) ohana_memcheck (TRUE);
 
   // since we init'ed the structures above, these operations are safe whether or not we compressed the table
@@ -217,5 +222,5 @@
   off_t Nskip;
   int status;
-  char *path, string[80];
+  char *path, string[256];
   Catalog *subcat;
 
@@ -241,6 +246,7 @@
     return (DVO_CAT_OPEN_FAIL);
   }
-  ALLOCATE (subcat[0].filename, char, strlen(path) + strlen(string) + 2);
-  sprintf (subcat[0].filename, "%s/%s", path, string);
+  int Nchar = strlen(path) + strlen(string) + 10;
+  ALLOCATE (subcat[0].filename, char, Nchar);
+  snprintf (subcat[0].filename, Nchar, "%s/%s", path, string);
   free (path);
 
@@ -308,5 +314,5 @@
     }
 
-    char compressMode[80];
+    char compressMode[256];
     if (!gfits_scan (ftable->header, "DVO_CMP", "%s", 1, compressMode)) {
       strcpy (compressMode, "AUTO");
@@ -785,4 +791,21 @@
 }
 
+# if (0)
+void compare_file_ptr (FILE *copy_ptr, FILE *real_ptr, char *name) {
+  return;
+
+  int i;
+  
+  char *real = (char *) real_ptr;
+  char *copy = (char *) copy_ptr;
+
+  for (i = 0; i < sizeof(FILE); i++, real++, copy++) {
+    if (*real != *copy) {
+      fprintf (stderr, "file pointers %s differ @ %d\n", name, (int) ((char *) real - (char *) real_ptr));
+    }
+  }
+}
+# endif
+
 /* save_catalog_split writes all data currently in memory to disk */
 int dvo_catalog_save_split (Catalog *catalog, char VERBOSE) {
@@ -871,4 +894,5 @@
       goto failure;
     }
+
     gfits_free_header (&header);
     gfits_free_table (&ftable);
@@ -913,4 +937,5 @@
       goto failure;
     }
+
     gfits_free_header (&header);
     gfits_free_table (&ftable);
