IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 25, 2015, 10:41:05 PM (11 years ago)
Author:
eugene
Message:

merge changes from branches/eam_branches/ipp-20150616

Location:
trunk/Ohana/src/dvomerge
Files:
13 edited

Legend:

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

    r38468 r38553  
    3030int    VERIFY_CATALOG_ONLY;
    3131int    IMAGES_ONLY;
    32 char   CATDIR[256];
    33 char   GSCFILE[256];
    34 char   CATMODE[16];    /* raw, mef, split, mysql */
    35 char   CATFORMAT[16];  /* internal, elixir, loneos, panstarrs */
    36 char   ImageCat[256];
     32char   CATDIR[DVO_MAX_PATH];
     33char   GSCFILE[DVO_MAX_PATH];
     34char   ImageCat[DVO_MAX_PATH];
     35char   CATMODE[256];    /* raw, mef, split, mysql */
     36char   CATFORMAT[256];  /* internal, elixir, loneos, panstarrs */
    3737float  RADIUS;
    3838int    SKY_DEPTH;
    3939int    NTHREADS;
    40 char  *ALTERNATE_PHOTCODE_FILE;
    4140int    REPLACE_BY_PHOTCODE;
    4241int    REPLACE_TYCHO;
    4342int    FORCE_MERGE;
    4443int    MAX_CLIENTS;
     44char  *ALTERNATE_PHOTCODE_FILE;
    4545char  *UPDATE_CATFORMAT;
    4646char  *UPDATE_CATCOMPRESS;
     
    116116void       dvomerge_help          PROTO((int argc, char **argv));
    117117int        dvomerge_args          PROTO((int *argc, char **argv));
     118void       dvomerge_args_free     PROTO((void));
    118119
    119120void       dvomerge_client_usage  PROTO((void));
     
    174175off_t      dvo_map_image_ID       PROTO((IDmapType *IDmap, off_t oldID));
    175176int        dvo_update_image_IDs   PROTO((IDmapType *IDmap, Catalog *catalog));
     177void       dvo_image_map_free     PROTO((IDmapType *IDmap));
     178void       dvo_image_map_init     PROTO((IDmapType *IDmap));
    176179
    177180// dvorepair prototypes
     
    212215int dmhObjectCheck (dmhObject *history, dmhObjectStats *inStats);
    213216dmhObject *dmhObjectRead (char *filename);
     217dmhObject *dmhObjectAlloc (void);
     218void dmhObjectFree (dmhObject *history);
    214219
    215220void dmhObjectStatsFree (dmhObjectStats *stats);
     
    217222
    218223int dmhImageAdd (FITS_DB *db, dmhImage *history, char *dbID);
    219 dmhImage *dmhImageRead (FITS_DB *db) ;
     224dmhImage *dmhImageRead (FITS_DB *db);
    220225int dmhImageCheck (dmhImage *history, char *dbID);
     226void dmhImageFree(dmhImage *history);
    221227
    222228char *dmhImageReadID (FITS_DB *db);
  • trunk/Ohana/src/dvomerge/include/dvoverify.h

    r37360 r38553  
    5353void AddFailures (char *filename);
    5454char **GetFailures (int *N);
     55void FreeFailures (void);
    5556
    5657int LoadImageIDs (char *catdir);
     
    5960int SaveImageIDsSmall(char *filename);
    6061int LoadImageIDsSmall (char *filename);
     62
     63void FreeImageIDs (void);
  • trunk/Ohana/src/dvomerge/src/ConfigInit.c

    r27435 r38553  
    4747  VERBOSE = TRUE;
    4848
     49  FreeConfigFile();
    4950  free (config);
    5051  free (file);
  • trunk/Ohana/src/dvomerge/src/args.c

    r38468 r38553  
    66  int N;
    77
     8  HOSTDIR = NULL;
     9  SINGLE_CPT = NULL;
     10
    811  /* extra error messages */
    912  VERBOSE = FALSE;
     
    5356
    5457  /* use a different photcode file to define mean values */
     58  ALTERNATE_PHOTCODE_FILE = NULL;
    5559  if ((N = get_argument (*argc, argv, "-photcode-file"))) {
    5660    remove_argument (N, argc, argv);
     
    156160}
    157161
     162void dvomerge_args_free (void) {
     163  FREE (HOSTDIR);
     164  FREE (ALTERNATE_PHOTCODE_FILE);
     165  FREE (UPDATE_CATFORMAT);
     166  FREE (UPDATE_CATCOMPRESS);
     167  FREE (SINGLE_CPT);
     168}
     169
    158170/*** check for command line options ***/
    159171int dvomerge_client_args (int *argc, char **argv) {
  • trunk/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c

    r38441 r38553  
    55void SortTgtByTimes (e_time *S, off_t *I, short *C, off_t N);
    66off_t getTgtIndex (e_time start, e_time stop, short photcode, off_t *TgtIndex, e_time *TgtTimes, short *TgtCodes, off_t NimagesTgt);
     7
     8void dvo_image_map_init (IDmapType *IDmap) {
     9  // we don't own the IDmap, just the elements
     10  IDmap->old = NULL;
     11  IDmap->new = NULL;
     12  IDmap->notFound = NULL;
     13  IDmap->Nmap = 0;
     14}
     15
     16void dvo_image_map_free (IDmapType *IDmap) {
     17  // we don't own the IDmap, just the elements
     18  FREE (IDmap->old);
     19  FREE (IDmap->new);
     20  FREE (IDmap->notFound);
     21}
    722
    823// we have two tables; 'tgt' contains some exposures from 'src' : find them and match a map
  • trunk/Ohana/src/dvomerge/src/dvomerge.c

    r35765 r38553  
    77  ConfigInit (&argc, argv);
    88  dvomerge_args (&argc, argv);
     9
     10  if ((argc < 4) || (argc > 6)) dvomerge_usage();
    911
    1012  if (argc == 6) {
     
    3840    }
    3941  }
    40   dvomerge_usage();
    41   exit (2); // cannot reach here.
     42  dvomerge_args_free ();
     43  ohana_memcheck (TRUE);
     44  ohana_memdump (TRUE);
     45  exit (0);
    4246}
    4347
  • trunk/Ohana/src/dvomerge/src/dvomergeHistory.c

    r34578 r38553  
    2828  char *ID = strcreate (dbID);
    2929  return ID;
     30}
     31
     32void dmhImageFree(dmhImage *history) {
     33  if (!history) return;
     34 
     35  int i;
     36  for (i = 0; i < history->Nmerge; i++) {
     37    FREE (history->IDs[i]);
     38  }
     39  FREE (history->IDs);
     40  FREE (history);
    3041}
    3142
     
    125136}
    126137
     138dmhObject *dmhObjectAlloc (void) {
     139
     140  dmhObject *history = NULL;
     141  ALLOCATE (history, dmhObject, 1);
     142  history->Nmerge = 0;
     143 
     144  // ALLOCATE full list
     145  ALLOCATE (history->size, off_t,  history->Nmerge);
     146  ALLOCATE (history->time, time_t, history->Nmerge);
     147  ALLOCATE (history->date, char *, history->Nmerge);
     148  return history;
     149}
     150
     151void dmhObjectFree (dmhObject *history) {
     152  if (!history) return;
     153
     154  FREE (history->size);
     155  FREE (history->time);
     156
     157  if (history->date) {
     158    int i;
     159    for (i = 0; i < history->Nmerge; i++) {
     160      FREE (history->date[i]);
     161    }
     162  }
     163  FREE (history->date);
     164  FREE (history);
     165  return;
     166}
     167
    127168// read the array of merged history information from this file's header
    128169dmhObject *dmhObjectRead (char *filename) {
     
    133174  if (stat_result) {
    134175    if (errno == ENOENT) {
    135       dmhObject *history = NULL;
    136       ALLOCATE (history, dmhObject, 1);
    137       history->Nmerge = 0;
    138    
    139       // ALLOCATE full list
    140       ALLOCATE (history->size, off_t,  history->Nmerge);
    141       ALLOCATE (history->time, time_t, history->Nmerge);
    142       ALLOCATE (history->date, char *, history->Nmerge);
     176      dmhObject *history = dmhObjectAlloc();
    143177      return history;
    144178    }
     
    162196  fclose (fout);
    163197
    164   dmhObject *history = NULL;
    165   ALLOCATE (history, dmhObject, 1);
     198  dmhObject *history = dmhObjectAlloc();
    166199
    167200  int status = gfits_scan (&outheader, "NMERGE", "%d", 1, &history->Nmerge);     
     
    171204
    172205  // ALLOCATE full list
    173   ALLOCATE (history->size, off_t,  history->Nmerge);
    174   ALLOCATE (history->time, time_t, history->Nmerge);
    175   ALLOCATE (history->date, char *, history->Nmerge);
     206  REALLOCATE (history->size, off_t,  history->Nmerge);
     207  REALLOCATE (history->time, time_t, history->Nmerge);
     208  REALLOCATE (history->date, char *, history->Nmerge);
    176209
    177210  int i;
     
    199232    history->time[i] = ohana_date_to_sec (date);
    200233  }
     234  gfits_free_header (&outheader);
    201235  return history;
    202236}
     
    239273  history->size[last] = inStats->size;
    240274  history->time[last] = inStats->time;
    241   history->date[last] = inStats->date;
     275  history->date[last] = strcreate (inStats->date);
    242276
    243277  char name[16];
     
    280314  int i;
    281315  for (i = 0; i < N; i++) {
    282     if (outstat[i].history)  { free (outstat[i].history); }
     316    if (outstat[i].history)  { dmhObjectFree (outstat[i].history); }
    283317    if (outstat[i].filename) { free (outstat[i].filename); }
    284318  }
  • trunk/Ohana/src/dvomerge/src/dvomergeImageIDs.c

    r38441 r38553  
    6464    dvo_image_match_dbs(IDmap, &outDB, &inDB);
    6565    dvo_image_unlock (&outDB); // unlock output
     66
     67    gfits_db_free (&inDB);
     68    gfits_db_free (&outDB);
     69    dmhImageFree (history);
     70    FREE (indbID);
    6671    return TRUE;
    6772  }
     
    8085  SetProtect (FALSE);
    8186  dvo_image_unlock (&outDB); // unlock output
     87
     88  gfits_db_free (&inDB);
     89  gfits_db_free (&outDB);
     90
     91  dmhImageFree (history);
     92  FREE (indbID);
    8293
    8394  return TRUE;
     
    136147  dvo_image_match_dbs(IDmap, &outDB, &inDB);
    137148
     149  gfits_db_free (&inDB);
     150  gfits_db_free (&outDB);
     151
    138152  return TRUE;
    139153}
  • trunk/Ohana/src/dvomerge/src/dvomergeUpdate.c

    r38468 r38553  
    88  char filename[256], *input, *output;
    99  IDmapType IDmap;
    10   PhotCodeData *inputPhotcodes;
    11   PhotCodeData *outputPhotcodes;
    1210  int *secfiltMap = NULL;
    1311  int NsecfiltInput, NsecfiltOutput;
    1412
    1513  INITTIME;
     14
     15  dvo_image_map_init (&IDmap);
    1616
    1717  CONTINUE = FALSE;
     
    3434    exit (1);
    3535  }
     36
     37  PhotCodeData *inputPhotcodes  = NULL;
     38  PhotCodeData *outputPhotcodes = NULL;
    3639
    3740  SetPhotcodeTable(NULL);
     
    120123    exit (1);
    121124  }
     125  FREE (skyfile);
     126
     127  SkyTableFree (insky);
     128  SkyTableFree (outsky);
     129  SkyListFree (inlist);
     130
     131  FREE (secfiltMap);
     132  dvo_image_map_free (&IDmap);
     133  if (outputPhotcodes != inputPhotcodes) { FreePhotcodeData (outputPhotcodes); }
     134  FreePhotcodeData (inputPhotcodes);
     135  FreePhotcodeTable ();
    122136
    123137  if (!status) {
     
    127141
    128142  MARKTIME ("SUCCESS: elapsed time %9.4f sec\n", dtime);
    129   exit (0);
     143  return TRUE;
    130144}
  • trunk/Ohana/src/dvomerge/src/dvoverify.c

    r34405 r38553  
    2424
    2525    // check the photcode table
    26     sprintf (filename, "%s/Photcodes.dat", CATDIR);
     26    myAssert (snprintf (filename, DVO_MAX_PATH, "%s/Photcodes.dat", CATDIR) < DVO_MAX_PATH, "overflow");
    2727    if (!VerifyTableFile (filename)) {
    2828      Nbad ++;
     
    3434      Nbad ++;
    3535    }
     36    free (skyfile);
    3637
    3738    // check the image table
    38     sprintf (filename, "%s/Images.dat", CATDIR);
     39    myAssert (snprintf (filename, DVO_MAX_PATH, "%s/Images.dat", CATDIR) < DVO_MAX_PATH, "overflow");
    3940    if (!VerifyTableFile (filename)) {
    4041      Nbad ++;
     
    7172    fprintf (stderr, "NOTE: %d files are not sorted\n", NNotSorted);
    7273  }
     74
     75  FreeImageIDs ();
     76  FreeFailures ();
     77  SkyTableFree (sky);
     78  SkyListFree (skylist);
     79
     80  ohana_memcheck (TRUE);
     81  ohana_memdump (TRUE);
    7382  exit (0);
    7483}
  • trunk/Ohana/src/dvomerge/src/dvoverify_args.c

    r37360 r38553  
    4545    }
    4646
     47    CHECK_IMAGE_ID = FALSE;
     48
    4749    int isGood = dvoverify_single (filename);
     50    free (filename);
     51
     52    ohana_memcheck (TRUE);
     53    ohana_memdump (TRUE);
     54
    4855    if (!isGood) exit (1);
    4956    exit (0);
  • trunk/Ohana/src/dvomerge/src/dvoverify_catalogs.c

    r37360 r38553  
    2727    if (!HostTableTestHost(skylist[0].regions[i], HOST_ID)) continue;
    2828
    29     sprintf (filename, "%s/%s.cpt", mycatdir, skylist[0].regions[i][0].name);
     29    myAssert (snprintf (filename, DVO_MAX_PATH, "%s/%s.cpt", mycatdir, skylist[0].regions[i][0].name) < DVO_MAX_PATH, "overflow");
    3030    if (!VerifyTableFile (filename)) {
    3131      Nbad ++;
     
    3434    }
    3535
    36     sprintf (filename, "%s/%s.cps", mycatdir, skylist[0].regions[i][0].name);
     36    myAssert (snprintf (filename, DVO_MAX_PATH, "%s/%s.cps", mycatdir, skylist[0].regions[i][0].name) < DVO_MAX_PATH, "overflow");
    3737    if (!VerifyTableFile (filename)) {
    3838      Nbad ++;
     
    4040    }
    4141
    42     sprintf (filename, "%s/%s.cpm", mycatdir, skylist[0].regions[i][0].name);
     42    myAssert (snprintf (filename, DVO_MAX_PATH, "%s/%s.cpm", mycatdir, skylist[0].regions[i][0].name) < DVO_MAX_PATH, "overflow");
    4343    if (!VerifyTableFile (filename)) {
    4444      Nbad ++;
     
    4747    }
    4848
    49     sprintf (filename, "%s/%s.cpx", mycatdir, skylist[0].regions[i][0].name);
     49    myAssert (snprintf (filename, DVO_MAX_PATH, "%s/%s.cpx", mycatdir, skylist[0].regions[i][0].name) < DVO_MAX_PATH, "overflow");
    5050    if (!VerifyTableFile (filename)) {
    5151      Nbad ++;
     
    5454    }
    5555
    56     sprintf (filename, "%s/%s.cpy", mycatdir, skylist[0].regions[i][0].name);
     56    myAssert (snprintf (filename, DVO_MAX_PATH, "%s/%s.cpy", mycatdir, skylist[0].regions[i][0].name) < DVO_MAX_PATH, "overflow");
    5757    if (!VerifyTableFile (filename)) {
    5858      Nbad ++;
     
    6161    }
    6262
    63     sprintf (filename, "%s/%s.cpt", mycatdir, skylist[0].regions[i][0].name);
     63    myAssert (snprintf (filename, DVO_MAX_PATH, "%s/%s.cpt", mycatdir, skylist[0].regions[i][0].name) < DVO_MAX_PATH, "overflow");
    6464    if (!skipIndexCheck) {
    6565      if (!CheckCatalogIndexes(filename, skylist[0].regions[i])){
  • trunk/Ohana/src/dvomerge/src/dvoverify_utils.c

    r38471 r38553  
    55static char **failures = NULL;
    66
    7 void InitFailures () {
    8   ALLOCATE (failures, char *, NFAILURES);
     7void InitFailures (void) {
     8  ALLOCATE_ZERO (failures, char *, NFAILURES);
     9}
     10
     11void FreeFailures (void) {
     12  int i;
     13
     14  if (!failures) return;
     15  for (i = 0; i < NFAILURES; i++) {
     16    FREE (failures[i]);
     17  }
     18  FREE (failures);
    919}
    1020
     
    128138        fprintf (stderr, "unable to read header for %s, extension %d (or file has excess bytes)\n", filename, Next);
    129139      }
    130       fclose(file);
     140      fclose (file);
     141      gfits_free_header (&header);
    131142      return (FALSE);
    132143    }
     
    175186
    176187  // set the parameters which guide catalog open/load/create
    177     dvo_catalog_init (&catalog, TRUE);
     188  dvo_catalog_init (&catalog, TRUE);
    178189  catalog.filename  = filename;
    179190  catalog.catflags  = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_LENSING | DVO_LOAD_LENSOBJ;
     
    183194  if (!dvo_catalog_open (&catalog, region, VERBOSE, "r")) {
    184195    fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
     196    dvo_catalog_free (&catalog);
    185197    return FALSE;
    186198  }
     
    463475
    464476  char ImageCat[DVO_MAX_PATH];
    465   snprintf (ImageCat, DVO_MAX_PATH, "%s/Images.dat", catdir);
     477  myAssert (snprintf (ImageCat, DVO_MAX_PATH, "%s/Images.dat", catdir) < DVO_MAX_PATH, "overflow");
    466478
    467479  // load the iage database table
     
    506518    IDlist[id] = i;
    507519  }
    508 
    509   // free image table here?
     520 
    510521  // (in the future, I'll have to do the image table read in segments
    511522  // it is just getting to be too large...)
    512523  dvo_image_unlock (&inDB); // unlock input
     524  gfits_db_free (&inDB);
    513525
    514526  return TRUE;
     527}
     528
     529void FreeImageIDs (void) {
     530  FREE (IDlist);
    515531}
    516532
Note: See TracChangeset for help on using the changeset viewer.