Changeset 38553 for trunk/Ohana/src/dvomerge
- Timestamp:
- Jun 25, 2015, 10:41:05 PM (11 years ago)
- Location:
- trunk/Ohana/src/dvomerge
- Files:
-
- 13 edited
-
include/dvomerge.h (modified) (5 diffs)
-
include/dvoverify.h (modified) (2 diffs)
-
src/ConfigInit.c (modified) (1 diff)
-
src/args.c (modified) (3 diffs)
-
src/dvo_image_merge_dbs.c (modified) (1 diff)
-
src/dvomerge.c (modified) (2 diffs)
-
src/dvomergeHistory.c (modified) (8 diffs)
-
src/dvomergeImageIDs.c (modified) (3 diffs)
-
src/dvomergeUpdate.c (modified) (4 diffs)
-
src/dvoverify.c (modified) (3 diffs)
-
src/dvoverify_args.c (modified) (1 diff)
-
src/dvoverify_catalogs.c (modified) (6 diffs)
-
src/dvoverify_utils.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/dvomerge/include/dvomerge.h
r38468 r38553 30 30 int VERIFY_CATALOG_ONLY; 31 31 int IMAGES_ONLY; 32 char CATDIR[ 256];33 char GSCFILE[ 256];34 char CATMODE[16]; /* raw, mef, split, mysql */35 char CAT FORMAT[16]; /* internal, elixir, loneos, panstarrs*/36 char ImageCat[256];32 char CATDIR[DVO_MAX_PATH]; 33 char GSCFILE[DVO_MAX_PATH]; 34 char ImageCat[DVO_MAX_PATH]; 35 char CATMODE[256]; /* raw, mef, split, mysql */ 36 char CATFORMAT[256]; /* internal, elixir, loneos, panstarrs */ 37 37 float RADIUS; 38 38 int SKY_DEPTH; 39 39 int NTHREADS; 40 char *ALTERNATE_PHOTCODE_FILE;41 40 int REPLACE_BY_PHOTCODE; 42 41 int REPLACE_TYCHO; 43 42 int FORCE_MERGE; 44 43 int MAX_CLIENTS; 44 char *ALTERNATE_PHOTCODE_FILE; 45 45 char *UPDATE_CATFORMAT; 46 46 char *UPDATE_CATCOMPRESS; … … 116 116 void dvomerge_help PROTO((int argc, char **argv)); 117 117 int dvomerge_args PROTO((int *argc, char **argv)); 118 void dvomerge_args_free PROTO((void)); 118 119 119 120 void dvomerge_client_usage PROTO((void)); … … 174 175 off_t dvo_map_image_ID PROTO((IDmapType *IDmap, off_t oldID)); 175 176 int dvo_update_image_IDs PROTO((IDmapType *IDmap, Catalog *catalog)); 177 void dvo_image_map_free PROTO((IDmapType *IDmap)); 178 void dvo_image_map_init PROTO((IDmapType *IDmap)); 176 179 177 180 // dvorepair prototypes … … 212 215 int dmhObjectCheck (dmhObject *history, dmhObjectStats *inStats); 213 216 dmhObject *dmhObjectRead (char *filename); 217 dmhObject *dmhObjectAlloc (void); 218 void dmhObjectFree (dmhObject *history); 214 219 215 220 void dmhObjectStatsFree (dmhObjectStats *stats); … … 217 222 218 223 int dmhImageAdd (FITS_DB *db, dmhImage *history, char *dbID); 219 dmhImage *dmhImageRead (FITS_DB *db) ;224 dmhImage *dmhImageRead (FITS_DB *db); 220 225 int dmhImageCheck (dmhImage *history, char *dbID); 226 void dmhImageFree(dmhImage *history); 221 227 222 228 char *dmhImageReadID (FITS_DB *db); -
trunk/Ohana/src/dvomerge/include/dvoverify.h
r37360 r38553 53 53 void AddFailures (char *filename); 54 54 char **GetFailures (int *N); 55 void FreeFailures (void); 55 56 56 57 int LoadImageIDs (char *catdir); … … 59 60 int SaveImageIDsSmall(char *filename); 60 61 int LoadImageIDsSmall (char *filename); 62 63 void FreeImageIDs (void); -
trunk/Ohana/src/dvomerge/src/ConfigInit.c
r27435 r38553 47 47 VERBOSE = TRUE; 48 48 49 FreeConfigFile(); 49 50 free (config); 50 51 free (file); -
trunk/Ohana/src/dvomerge/src/args.c
r38468 r38553 6 6 int N; 7 7 8 HOSTDIR = NULL; 9 SINGLE_CPT = NULL; 10 8 11 /* extra error messages */ 9 12 VERBOSE = FALSE; … … 53 56 54 57 /* use a different photcode file to define mean values */ 58 ALTERNATE_PHOTCODE_FILE = NULL; 55 59 if ((N = get_argument (*argc, argv, "-photcode-file"))) { 56 60 remove_argument (N, argc, argv); … … 156 160 } 157 161 162 void 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 158 170 /*** check for command line options ***/ 159 171 int dvomerge_client_args (int *argc, char **argv) { -
trunk/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c
r38441 r38553 5 5 void SortTgtByTimes (e_time *S, off_t *I, short *C, off_t N); 6 6 off_t getTgtIndex (e_time start, e_time stop, short photcode, off_t *TgtIndex, e_time *TgtTimes, short *TgtCodes, off_t NimagesTgt); 7 8 void 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 16 void 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 } 7 22 8 23 // 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 7 7 ConfigInit (&argc, argv); 8 8 dvomerge_args (&argc, argv); 9 10 if ((argc < 4) || (argc > 6)) dvomerge_usage(); 9 11 10 12 if (argc == 6) { … … 38 40 } 39 41 } 40 dvomerge_usage(); 41 exit (2); // cannot reach here. 42 dvomerge_args_free (); 43 ohana_memcheck (TRUE); 44 ohana_memdump (TRUE); 45 exit (0); 42 46 } 43 47 -
trunk/Ohana/src/dvomerge/src/dvomergeHistory.c
r34578 r38553 28 28 char *ID = strcreate (dbID); 29 29 return ID; 30 } 31 32 void 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); 30 41 } 31 42 … … 125 136 } 126 137 138 dmhObject *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 151 void 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 127 168 // read the array of merged history information from this file's header 128 169 dmhObject *dmhObjectRead (char *filename) { … … 133 174 if (stat_result) { 134 175 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(); 143 177 return history; 144 178 } … … 162 196 fclose (fout); 163 197 164 dmhObject *history = NULL; 165 ALLOCATE (history, dmhObject, 1); 198 dmhObject *history = dmhObjectAlloc(); 166 199 167 200 int status = gfits_scan (&outheader, "NMERGE", "%d", 1, &history->Nmerge); … … 171 204 172 205 // 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); 176 209 177 210 int i; … … 199 232 history->time[i] = ohana_date_to_sec (date); 200 233 } 234 gfits_free_header (&outheader); 201 235 return history; 202 236 } … … 239 273 history->size[last] = inStats->size; 240 274 history->time[last] = inStats->time; 241 history->date[last] = inStats->date;275 history->date[last] = strcreate (inStats->date); 242 276 243 277 char name[16]; … … 280 314 int i; 281 315 for (i = 0; i < N; i++) { 282 if (outstat[i].history) { free (outstat[i].history); }316 if (outstat[i].history) { dmhObjectFree (outstat[i].history); } 283 317 if (outstat[i].filename) { free (outstat[i].filename); } 284 318 } -
trunk/Ohana/src/dvomerge/src/dvomergeImageIDs.c
r38441 r38553 64 64 dvo_image_match_dbs(IDmap, &outDB, &inDB); 65 65 dvo_image_unlock (&outDB); // unlock output 66 67 gfits_db_free (&inDB); 68 gfits_db_free (&outDB); 69 dmhImageFree (history); 70 FREE (indbID); 66 71 return TRUE; 67 72 } … … 80 85 SetProtect (FALSE); 81 86 dvo_image_unlock (&outDB); // unlock output 87 88 gfits_db_free (&inDB); 89 gfits_db_free (&outDB); 90 91 dmhImageFree (history); 92 FREE (indbID); 82 93 83 94 return TRUE; … … 136 147 dvo_image_match_dbs(IDmap, &outDB, &inDB); 137 148 149 gfits_db_free (&inDB); 150 gfits_db_free (&outDB); 151 138 152 return TRUE; 139 153 } -
trunk/Ohana/src/dvomerge/src/dvomergeUpdate.c
r38468 r38553 8 8 char filename[256], *input, *output; 9 9 IDmapType IDmap; 10 PhotCodeData *inputPhotcodes;11 PhotCodeData *outputPhotcodes;12 10 int *secfiltMap = NULL; 13 11 int NsecfiltInput, NsecfiltOutput; 14 12 15 13 INITTIME; 14 15 dvo_image_map_init (&IDmap); 16 16 17 17 CONTINUE = FALSE; … … 34 34 exit (1); 35 35 } 36 37 PhotCodeData *inputPhotcodes = NULL; 38 PhotCodeData *outputPhotcodes = NULL; 36 39 37 40 SetPhotcodeTable(NULL); … … 120 123 exit (1); 121 124 } 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 (); 122 136 123 137 if (!status) { … … 127 141 128 142 MARKTIME ("SUCCESS: elapsed time %9.4f sec\n", dtime); 129 exit (0);143 return TRUE; 130 144 } -
trunk/Ohana/src/dvomerge/src/dvoverify.c
r34405 r38553 24 24 25 25 // 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"); 27 27 if (!VerifyTableFile (filename)) { 28 28 Nbad ++; … … 34 34 Nbad ++; 35 35 } 36 free (skyfile); 36 37 37 38 // 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"); 39 40 if (!VerifyTableFile (filename)) { 40 41 Nbad ++; … … 71 72 fprintf (stderr, "NOTE: %d files are not sorted\n", NNotSorted); 72 73 } 74 75 FreeImageIDs (); 76 FreeFailures (); 77 SkyTableFree (sky); 78 SkyListFree (skylist); 79 80 ohana_memcheck (TRUE); 81 ohana_memdump (TRUE); 73 82 exit (0); 74 83 } -
trunk/Ohana/src/dvomerge/src/dvoverify_args.c
r37360 r38553 45 45 } 46 46 47 CHECK_IMAGE_ID = FALSE; 48 47 49 int isGood = dvoverify_single (filename); 50 free (filename); 51 52 ohana_memcheck (TRUE); 53 ohana_memdump (TRUE); 54 48 55 if (!isGood) exit (1); 49 56 exit (0); -
trunk/Ohana/src/dvomerge/src/dvoverify_catalogs.c
r37360 r38553 27 27 if (!HostTableTestHost(skylist[0].regions[i], HOST_ID)) continue; 28 28 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"); 30 30 if (!VerifyTableFile (filename)) { 31 31 Nbad ++; … … 34 34 } 35 35 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"); 37 37 if (!VerifyTableFile (filename)) { 38 38 Nbad ++; … … 40 40 } 41 41 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"); 43 43 if (!VerifyTableFile (filename)) { 44 44 Nbad ++; … … 47 47 } 48 48 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"); 50 50 if (!VerifyTableFile (filename)) { 51 51 Nbad ++; … … 54 54 } 55 55 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"); 57 57 if (!VerifyTableFile (filename)) { 58 58 Nbad ++; … … 61 61 } 62 62 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"); 64 64 if (!skipIndexCheck) { 65 65 if (!CheckCatalogIndexes(filename, skylist[0].regions[i])){ -
trunk/Ohana/src/dvomerge/src/dvoverify_utils.c
r38471 r38553 5 5 static char **failures = NULL; 6 6 7 void InitFailures () { 8 ALLOCATE (failures, char *, NFAILURES); 7 void InitFailures (void) { 8 ALLOCATE_ZERO (failures, char *, NFAILURES); 9 } 10 11 void 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); 9 19 } 10 20 … … 128 138 fprintf (stderr, "unable to read header for %s, extension %d (or file has excess bytes)\n", filename, Next); 129 139 } 130 fclose(file); 140 fclose (file); 141 gfits_free_header (&header); 131 142 return (FALSE); 132 143 } … … 175 186 176 187 // set the parameters which guide catalog open/load/create 177 dvo_catalog_init (&catalog, TRUE);188 dvo_catalog_init (&catalog, TRUE); 178 189 catalog.filename = filename; 179 190 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_LENSING | DVO_LOAD_LENSOBJ; … … 183 194 if (!dvo_catalog_open (&catalog, region, VERBOSE, "r")) { 184 195 fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename); 196 dvo_catalog_free (&catalog); 185 197 return FALSE; 186 198 } … … 463 475 464 476 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"); 466 478 467 479 // load the iage database table … … 506 518 IDlist[id] = i; 507 519 } 508 509 // free image table here? 520 510 521 // (in the future, I'll have to do the image table read in segments 511 522 // it is just getting to be too large...) 512 523 dvo_image_unlock (&inDB); // unlock input 524 gfits_db_free (&inDB); 513 525 514 526 return TRUE; 527 } 528 529 void FreeImageIDs (void) { 530 FREE (IDlist); 515 531 } 516 532
Note:
See TracChangeset
for help on using the changeset viewer.
