IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 39579


Ignore:
Timestamp:
May 26, 2016, 1:34:24 PM (10 years ago)
Author:
eugene
Message:

plug memory leaks; allow object to have no measurements

Location:
trunk/Ohana/src/delstar
Files:
6 edited

Legend:

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

    r39307 r39579  
    8383char        *SINGLE_CPT;
    8484
    85 int SKIP_IMAGES;
     85int   SAVE_DUPLICATES;
     86int   SKIP_IMAGES;
    8687
    8788time_t    START;
     
    138139int args_client (int argc, char **argv);
    139140
     141void delstar_args_free ();
     142void delstar_client_args_free ();
     143
    140144void SortAveMeasMatch (off_t *MEAS, off_t *AVE, off_t N);
    141145
  • trunk/Ohana/src/delstar/src/ConfigInit.c

    r34749 r39579  
    5454  }
    5555
     56  FreeConfigFile();
    5657  free (config);
    5758  free (file);
  • trunk/Ohana/src/delstar/src/args.c

    r39307 r39579  
    194194    SKIP_IMAGES = TRUE; // we do not need to load the images for -dup-measures
    195195  }
     196
     197  SAVE_DUPLICATES = FALSE;
     198  if ((N = get_argument (argc, argv, "-save-duplicates"))) {
     199    SAVE_DUPLICATES = TRUE;
     200    remove_argument (N, &argc, argv);
     201  }
     202
    196203  if ((N = get_argument (argc, argv, "-fix-LAP"))) {
    197204    if (MODE != MODE_NONE) usage();
     
    316323}
    317324
     325void delstar_args_free () {
     326  FREE (SINGLE_CPT);
     327  FREE (IMAGENAME);
     328  FREE (UNIQUER);
     329  FREE (CATDIR);
     330  FREE (EDGE_DELETIONS);
     331  FREE (PHOTCODE_LIST);
     332  FREE (IMSTATS_FILE);
     333}
     334
    318335int args_client (int argc, char **argv) {
    319336 
     
    453470  }
    454471
     472  SAVE_DUPLICATES = FALSE;
     473  if ((N = get_argument (argc, argv, "-save-duplicates"))) {
     474    SAVE_DUPLICATES = TRUE;
     475    remove_argument (N, &argc, argv);
     476  }
     477
    455478  MEASURE_EDGE_FILE = NULL;
    456479  if (MODE == MODE_FIX_LAP_EDGES) {
     
    484507  return (TRUE);
    485508}
     509
     510void delstar_client_args_free () {
     511  FREE (CATDIR);
     512  FREE (HOSTDIR);
     513  FREE (SINGLE_CPT);
     514  FREE (IMAGES);
     515  FREE (PHOTCODE_LIST);
     516  FREE (EDGE_DELETIONS);
     517  FREE (MEASURE_EDGE_FILE);
     518  FREE (IMSTATS_FILE);
     519}
     520
  • trunk/Ohana/src/delstar/src/delete_duplicate_measures.c

    r38986 r39579  
    3131  if (PARALLEL && !HOST_ID) {
    3232    int status = delete_duplicate_measures_parallel (skylist);
     33
     34    SkyTableFree (sky);
     35    SkyListFree (skylist);
     36    FreePhotcodeTable ();
     37
    3338    return status;
    3439  }
     
    7984    dvo_catalog_free (&catalog);
    8085  }
     86
     87  SkyTableFree (sky);
     88  SkyListFree (skylist);
     89  FreePhotcodeTable ();
     90
    8191  return TRUE;
    8292}
     
    117127    table->hosts[i].pathname = tmppath;
    118128
    119     char command[1024];
    120     snprintf (command, 1024, "delstar_client -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -dup-measures",
     129    char *command = NULL;
     130    strextend (&command, "delstar_client -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -dup-measures",
    121131              table->hosts[i].hostID, CATDIR, table->hosts[i].pathname,
    122132              UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax);
    123133
    124     char tmpline[1024];
    125     if (VERBOSE)    { snprintf (tmpline, 1024, "%s -v",      command);             strcpy (command, tmpline); }
    126     if (VERBOSE2)   { snprintf (tmpline, 1024, "%s -vv",     command);             strcpy (command, tmpline); }
    127     if (SINGLE_CPT) { snprintf (tmpline, 1024, "%s -cpt %s", command, SINGLE_CPT); strcpy (command, tmpline); }
    128     if (UPDATE)     { snprintf (tmpline, 1024, "%s -update", command);             strcpy (command, tmpline); }
     134    if (VERBOSE)         { strextend (&command, "-v");                  }
     135    if (VERBOSE2)        { strextend (&command, "-vv");                }
     136    if (SINGLE_CPT)      { strextend (&command, "-cpt %s", SINGLE_CPT); }
     137    if (UPDATE)          { strextend (&command, "-update");            }
     138    if (SAVE_DUPLICATES) { strextend (&command, "-save-duplicates");    }
    129139
    130140    fprintf (stderr, "command: %s\n", command);
    131141
    132     if (PARALLEL_MANUAL) continue;
     142    if (PARALLEL_MANUAL) {
     143      free (command);
     144      continue;
     145    }
    133146
    134147    if (PARALLEL_SERIAL) {
     
    148161      table->hosts[i].pid = pid; // save for future reference
    149162    }
     163    free (command);
    150164  }
    151165
     
    157171    HostTableWaitJobsGetIO (table, __FILE__, __LINE__, VERBOSE);
    158172  }
     173
     174  FreeHostTable(table);
    159175
    160176  return TRUE;
     
    211227  memset (duplicates,  0, sizeof(int) * Nmeasure);
    212228
     229  for (i = 0; i < Naverage; i++) {
     230    averageNmeas[i] = 0;
     231    averageDmeas[i] = -1;
     232  }
     233
    213234  // make an array of the full IDs
    214235  for (i = 0; i < Nmeasure; i++) {
     
    236257  }
    237258   
     259  FILE *fsave = NULL;
     260  if (SAVE_DUPLICATES) {
     261    char savename[DVO_MAX_PATH];
     262    snprintf (savename, DVO_MAX_PATH, "%s.save", catalog->filename);
     263    struct stat filestat;
     264    int myStatus = stat (savename, &filestat);
     265    if (myStatus && (errno == ENOENT)) {
     266      fsave = fopen (savename, "w");
     267      if (!fsave) {
     268        fprintf (stderr, "problem opening file %s for output\n", savename);
     269      }
     270    } else {
     271      if (!myStatus) {
     272        fprintf (stderr, "file %s exists: will not overwrite\n", savename);
     273      }
     274    }
     275  }   
     276
    238277  // mark the measures to be dropped
    239278  for (i = 0; i < Nmeasure; i++) {
     
    243282    off_t N = measure[j].averef;
    244283    if (VERBOSE) fprintf (stderr, "0x%08x 0x%08x %8.4f %8.4f %5d\n", measure[j].imageID, measure[j].detID, average[N].R, average[N].D, measure[j].photcode);
    245   }
     284    if (fsave) {
     285      fprintf (fsave, "0x%08x 0x%08x %8.4f %8.4f %5d\n", measure[j].imageID, measure[j].detID, average[N].R, average[N].D, measure[j].photcode);
     286    }
     287  }
     288 
     289  if (fsave) fclose (fsave);
    246290
    247291  // set up the measure sequence lists
     
    267311  // n = measureRefOut[i] : measureOut[n] = measure[i]
    268312  ALLOCATE (measureAveOut, off_t, NmeasOut);
     313
     314
    269315
    270316  // count the number of measures for each averef
     
    293339
    294340  // generate the new average sequence, skipping entries with no measurements
     341  // update 20160524 : keep entries with no measurements
    295342  off_t NaveOut = 0;
    296343  for (i = 0; i < Naverage; i++) {
    297     if (averageNmeas[i] == 0) continue;
     344    // if (averageNmeas[i] == 0) continue;
    298345    averageSeqOut[NaveOut] = i;
    299346    averageRefOut[i] = NaveOut;
  • trunk/Ohana/src/delstar/src/delstar.c

    r38441 r39579  
    2727    case MODE_DUP_MEASURES:
    2828      if (!delete_duplicate_measures ()) exit (1);
     29      delstar_args_free ();
     30      ohana_memcheck (TRUE);
     31      ohana_memdump (TRUE);
    2932      exit (0);
    3033      break;
  • trunk/Ohana/src/delstar/src/delstar_client.c

    r35758 r39579  
    2323      }
    2424      if (!delete_duplicate_image_measures (imageID)) exit (1);
     25      delstar_client_args_free ();
     26      ohana_memcheck (TRUE);
     27      ohana_memdump (TRUE);
    2528      exit (0);
    2629      break;
    2730    case MODE_DUP_MEASURES:
    2831      if (!delete_duplicate_measures ()) exit (1);
     32      delstar_client_args_free ();
     33      ohana_memcheck (TRUE);
     34      ohana_memdump (TRUE);
    2935      exit (0);
    3036      break;
Note: See TracChangeset for help on using the changeset viewer.