IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41429


Ignore:
Timestamp:
Oct 16, 2020, 9:49:13 AM (6 years ago)
Author:
eugene
Message:

add a test to dvosplit; plug memory leaks

Location:
trunk/Ohana/src/dvosplit
Files:
32 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/dvosplit/include/dvosplit.h

    r40561 r41429  
    2424int    FULL_TABLE;
    2525int    VERBOSE;
     26int    SKIP_EXIST; // do not re-split existing files
    2627char  *OUTDIR;
    2728char  *CATMODE;    /* raw, mef, split, mysql */
     
    4243int        split_averages         PROTO((Catalog *incatalog, SkyList *outlist, Catalog *outcatalogs));
    4344int        split_measures         PROTO((Catalog *incatalog, SkyList *outlist, Catalog *outcatalogs, AveLinks *avelinks));
    44 void GetConfig (char *config, char *field, char *format, int N, void *ptr);
     45void       GetConfig              PROTO((char *config, char *field, char *format, int N, void *ptr));
     46
     47void       dvosplit_free          PROTO((SkyTable *sky, SkyList *skylist));
  • trunk/Ohana/src/dvosplit/src/ConfigInit.c

    r33656 r41429  
    2121  SetZeroPoint (ZERO_POINT);
    2222
     23  FreeConfigFile();
    2324  free (config);
    2425  free (file);
  • trunk/Ohana/src/dvosplit/src/args.c

    r37807 r41429  
    7171  }
    7272
     73  /* extra error messages */
     74  SKIP_EXIST = FALSE;
     75  if ((N = get_argument (argc, argv, "-skip-exist"))) {
     76    SKIP_EXIST = TRUE;
     77    remove_argument (N, &argc, argv);
     78  }
     79
    7380  if (argc == 3) {
    7481    if (CONFIRM) {
     
    8693  fprintf (stderr, "USAGE: dvosplit (catdir) (newlevel) [-outdir outdir] [-region (Rmin) (Rmax) (Dmin) (Dmax)]\n");
    8794  exit (2);
     95}
     96
     97// XXX need to free sky
     98void dvosplit_free (SkyTable *sky, SkyList *skylist) {
     99  FREE (OUTDIR);
     100  FREE (CATMODE);
     101  FREE (CATFORMAT);
     102
     103  SkyTableFree (sky);
     104  SkyListFree(skylist);
     105  FreePhotcodeTable();
     106 
     107  ohana_memcheck (VERBOSE);
     108  ohana_memdump (VERBOSE);
    88109}
    89110
  • trunk/Ohana/src/dvosplit/src/dvosplit.c

    r40561 r41429  
    11# include "dvosplit.h"
     2
     3void dvosplit_free_outlist (SkyList *outlist);
    24
    35// dvosplit (catdir) (outlevel) [-outdir (outcat)} [-region Rmin Rmax Dmin Dmax]
     
    5557  for (i = 0; i < skylist[0].Nregions; i++) {
    5658    if (VERBOSE) fprintf (stderr, "%s\n", skylist[0].regions[i][0].name);
    57     fprintf (stderr, "reading from %s\n", skylist[0].regions[i][0].name);
     59    // fprintf (stderr, "reading from %s\n", skylist[0].regions[i][0].name);
    5860
    5961    // if !LocalCopy, always copy the file
     
    6769
    6870    if (LocalCopy && (skylist[0].regions[i][0].depth == OUT_DEPTH)) continue;
     71
     72    if (SKIP_EXIST) {
     73      int allFound = TRUE;
     74      for (j = 0; allFound && (j < outlist[0].Nregions); j++) {
     75        // check that outlist[0].filename[j] exists
     76        struct stat filestat;
     77        int fstatus = stat (outlist[0].filename[j], &filestat);
     78        if (fstatus) allFound = FALSE;
     79      }
     80      if (allFound) {
     81        fprintf (stderr, "skipping %s, already split\n", skylist[0].regions[i][0].name);
     82        dvosplit_free_outlist (outlist);
     83        continue;
     84      }
     85    }
    6986
    7087    // set the parameters which guide catalog open/load/create
     
    85102      dvo_catalog_unlock (&incatalog);
    86103      dvo_catalog_free (&incatalog);
     104      if (SKIP_EXIST) dvosplit_free_outlist (outlist);
    87105      continue;
    88106    }
     107
     108    // find the list of output filenames (do not yet open)
     109    // we need to check if we have already done the split
    89110
    90111    // change sky.regions[i].depth for these regions
     
    104125
    105126    dvo_catalog_unlock (&incatalog);
     127    dvo_catalog_free (&incatalog);
    106128
    107129    for (j = 0; j < outlist[0].Nregions; j++) {
     
    110132      dvo_catalog_save (&outcatalogs[j], VERBOSE);
    111133      dvo_catalog_unlock (&outcatalogs[j]);
     134      dvo_catalog_free (&outcatalogs[j]);
    112135    }
     136    FREE (outcatalogs);
    113137
    114138    // adjust depth
     
    134158    exit (1);
    135159  }
     160  free (filename);
    136161
    137162  if (!LocalCopy) {
     
    146171  }
    147172
     173  free (CATDIR);
     174  dvosplit_free (sky, skylist);
    148175  exit (0);
    149176}
     177
     178void dvosplit_free_outlist (SkyList *outlist) {
     179
     180  // free outlist & continue
     181  for (int j = 0; j < outlist[0].Nregions; j++) {
     182    free (outlist[0].filename[j]);
     183  }
     184  // free the rest of the list
     185  SkyListFree (outlist);
     186  return;
     187}
  • trunk/Ohana/src/dvosplit/src/dvosplitsky.c

    r41425 r41429  
    2323  // load the sky table for the existing database
    2424  SkyTable *sky = SkyTableLoadOptimal (CATDIR, NULL, NULL, TRUE, SKY_DEPTH_HST, VERBOSE);
    25   // SkyTableSetFilenames (sky, CATDIR, "cpt"); XXX probably not needed
     25  if (!sky) {
     26    fprintf (stderr, "ERROR: failed to read sky table from %s\n", CATDIR);
     27    exit (2);
     28  }
    2629
    2730  // for L4 entries in a certain ra,dec range, generate L5 entries:
Note: See TracChangeset for help on using the changeset viewer.