IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38506


Ignore:
Timestamp:
Jun 20, 2015, 1:30:59 PM (11 years ago)
Author:
eugene
Message:

use a dynamic string for compression mode; unlink other files if one fails; turn off memchecks in save_subcat; replace an sprintf with an snprintf; bump static string sizes

Location:
branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/dvo_catalog.c

    r38484 r38506  
    8585
    8686// we can return a static string here unless we run multiple outputs threads at once
    87 static char compress_string[16];
    8887char *dvo_catalog_compress_string (DVOCatCompress catcompress) {
    89 
     88  char *compress_string = NULL;
    9089  switch (catcompress) {
    9190    case DVO_COMPRESS_NONE:
    92       strcpy (compress_string, "NONE");
     91      compress_string = strcreate("NONE");
    9392      break;
    9493    case DVO_COMPRESS_AUTO:
    95       strcpy (compress_string, "AUTO");
     94      compress_string = strcreate("AUTO");
    9695      break;
    9796    case DVO_COMPRESS_GZIP_1:
    98       strcpy (compress_string, "GZIP_1");
     97      compress_string = strcreate("GZIP_1");
    9998      break;
    10099    case DVO_COMPRESS_GZIP_2:
    101       strcpy (compress_string, "GZIP_2");
     100      compress_string = strcreate("GZIP_2");
    102101      break;
    103102    case DVO_COMPRESS_NONE_1:
    104       strcpy (compress_string, "NONE_1");
     103      compress_string = strcreate("NONE_1");
    105104      break;
    106105    case DVO_COMPRESS_NONE_2:
    107       strcpy (compress_string, "NONE_2");
     106      compress_string = strcreate("NONE_2");
    108107      break;
    109108    case DVO_COMPRESS_RICE_1:
    110       strcpy (compress_string, "RICE_1");
     109      compress_string = strcreate("RICE_1");
    111110      break;
    112111    default:
     
    11581157    return FALSE;
    11591158  }
    1160      
     1159 
     1160  int outStatus = TRUE;
    11611161  status = unlink (tmpfilename);
    11621162  if (status) {
     1163    perror ("unlink: ");
    11631164    fprintf (stderr, "failed to unlink catalog %s~\n", catalog->filename);
    1164     return FALSE;
     1165    outStatus = FALSE;
    11651166  }
    11661167     
     
    11681169    if (catalog[0].measure_catalog != NULL) {
    11691170      if (!dvo_catalog_unlink_backup (catalog[0].measure_catalog, FALSE)) {
    1170         return FALSE;
     1171        outStatus = FALSE;
    11711172      }
    11721173    }
    11731174    if (catalog[0].missing_catalog != NULL) {
    11741175      if (!dvo_catalog_unlink_backup (catalog[0].missing_catalog, FALSE)) {
    1175         return FALSE;
     1176        outStatus = FALSE;
    11761177      }
    11771178    }
    11781179    if (catalog[0].secfilt_catalog != NULL) {
    11791180      if (!dvo_catalog_unlink_backup (catalog[0].secfilt_catalog, FALSE)) {
    1180         return FALSE;
     1181        outStatus = FALSE;
    11811182      }
    11821183    }
    11831184    if ((catalog[0].lensing_catalog != NULL) && (catalog[0].Nlensing_disk > 0)) {
    11841185      if (!dvo_catalog_unlink_backup (catalog[0].lensing_catalog, FALSE)) {
    1185         return FALSE;
     1186        outStatus = FALSE;
    11861187      }
    11871188    }
    11881189    if ((catalog[0].lensobj_catalog != NULL) && (catalog[0].Nlensobj_disk > 0)) {
    11891190      if (!dvo_catalog_unlink_backup (catalog[0].lensobj_catalog, FALSE)) {
    1190         return FALSE;
     1191        outStatus = FALSE;
    11911192      }
    11921193    }
    11931194    if ((catalog[0].starpar_catalog != NULL) && (catalog[0].Nstarpar_disk > 0)) {
    11941195      if (!dvo_catalog_unlink_backup (catalog[0].starpar_catalog, FALSE)) {
    1195         return FALSE;
     1196        outStatus = FALSE;
    11961197      }
    11971198    }
    11981199    if ((catalog[0].galphot_catalog != NULL) && (catalog[0].Ngalphot_disk > 0)) {
    11991200      if (!dvo_catalog_unlink_backup (catalog[0].galphot_catalog, FALSE)) {
    1200         return FALSE;
    1201       }
    1202     }
    1203   }
    1204   return TRUE;
    1205 }
    1206 
    1207 
     1201        outStatus = FALSE;
     1202      }
     1203    }
     1204  }
     1205  return outStatus;
     1206}
     1207
     1208
  • branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/dvo_catalog_split.c

    r38494 r38506  
    11# include <dvo.h>
    2 # define OHANA_MEMCHECK 1
     2# define OHANA_MEMCHECK 0
    33
    44// return options:
     
    9090int dvo_catalog_save_subcat (Catalog *catalog, FTable *ftable, off_t start, off_t Nrows, off_t Ndisk, off_t Ntotal) {
    9191
    92   Matrix matrix;
    93  
    94   // if (OHANA_MEMCHECK) ohana_memcheck (TRUE);
     92  if (OHANA_MEMCHECK) ohana_memcheck (TRUE);
    9593 
    9694  /* rewind file pointers and truncate (file is still open) */
     
    108106  off_t fullsize = catalog->header.datasize;
    109107
     108# if (1)
    110109  // write the PHU matrix; this is probably a NOP, do I have to keep it in?
     110  Matrix matrix;
    111111  gfits_create_matrix (&catalog->header, &matrix);
    112112  if (!gfits_fwrite_matrix  (catalog->f, &matrix)) {
     
    117117  fullsize += matrix.datasize;
    118118  gfits_free_matrix (&matrix);
     119# endif
    119120
    120121  FTable *outtable = ftable;
     
    128129  int isCompressed = output_is_compressed (start, Nrows, Ntotal, catalog->catcompress);
    129130
    130   // if (OHANA_MEMCHECK) ohana_memcheck (TRUE);
     131  if (OHANA_MEMCHECK) ohana_memcheck (TRUE);
    131132
    132133  if (isCompressed) {
     
    136137    if (!gfits_compress_table (ftable, &cmptable, 1000, compressMode)) {
    137138      fprintf (stderr, "compression failure\n");
     139      free (compressMode);
    138140      return (FALSE);
    139141    }
    140142    if (!byteswap_varlength_ftable (&cmpheader, &cmptable)) {
    141143      fprintf (stderr, "failed to swap varlength column\n");
     144      free (compressMode);
    142145      return FALSE;
    143146    }
    144147    if (!gfits_modify (cmptable.header, "DVO_CMP", "%s", 1, compressMode)) {
    145148      fprintf (stderr, "can't save compression mode\n");
    146       return (FALSE);
    147     }
     149      free (compressMode);
     150      return (FALSE);
     151    }
     152    free (compressMode);
    148153    outtable = &cmptable;
    149154  }
    150155
    151   // if (OHANA_MEMCHECK) ohana_memcheck (TRUE);
     156  if (OHANA_MEMCHECK) ohana_memcheck (TRUE);
    152157
    153158  // write the table data
     
    170175
    171176  // XXX test of repeated failure
    172   {
     177  if (0) {
    173178    Matrix myMatrix;
    174179
     
    195200  }
    196201
    197   // if (OHANA_MEMCHECK) ohana_memcheck (TRUE);
     202  if (OHANA_MEMCHECK) ohana_memcheck (TRUE);
    198203
    199204  // since we init'ed the structures above, these operations are safe whether or not we compressed the table
     
    217222  off_t Nskip;
    218223  int status;
    219   char *path, string[80];
     224  char *path, string[256];
    220225  Catalog *subcat;
    221226
     
    241246    return (DVO_CAT_OPEN_FAIL);
    242247  }
    243   ALLOCATE (subcat[0].filename, char, strlen(path) + strlen(string) + 2);
    244   sprintf (subcat[0].filename, "%s/%s", path, string);
     248  int Nchar = strlen(path) + strlen(string) + 10;
     249  ALLOCATE (subcat[0].filename, char, Nchar);
     250  snprintf (subcat[0].filename, Nchar, "%s/%s", path, string);
    245251  free (path);
    246252
     
    308314    }
    309315
    310     char compressMode[80];
     316    char compressMode[256];
    311317    if (!gfits_scan (ftable->header, "DVO_CMP", "%s", 1, compressMode)) {
    312318      strcpy (compressMode, "AUTO");
     
    785791}
    786792
     793# if (0)
     794void compare_file_ptr (FILE *copy_ptr, FILE *real_ptr, char *name) {
     795  return;
     796
     797  int i;
     798 
     799  char *real = (char *) real_ptr;
     800  char *copy = (char *) copy_ptr;
     801
     802  for (i = 0; i < sizeof(FILE); i++, real++, copy++) {
     803    if (*real != *copy) {
     804      fprintf (stderr, "file pointers %s differ @ %d\n", name, (int) ((char *) real - (char *) real_ptr));
     805    }
     806  }
     807}
     808# endif
     809
    787810/* save_catalog_split writes all data currently in memory to disk */
    788811int dvo_catalog_save_split (Catalog *catalog, char VERBOSE) {
     
    871894      goto failure;
    872895    }
     896
    873897    gfits_free_header (&header);
    874898    gfits_free_table (&ftable);
     
    913937      goto failure;
    914938    }
     939
    915940    gfits_free_header (&header);
    916941    gfits_free_table (&ftable);
Note: See TracChangeset for help on using the changeset viewer.