Changeset 28958
- Timestamp:
- Aug 18, 2010, 7:38:20 PM (16 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 7 edited
-
dvo/ImageSelection.c (modified) (1 diff)
-
dvo/LoadImages.c (modified) (3 diffs)
-
dvo/gimages.c (modified) (1 diff)
-
dvo/images.c (modified) (1 diff)
-
dvo/imdense.c (modified) (1 diff)
-
dvo/imextract.c (modified) (1 diff)
-
include/dvoshell.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/dvo/ImageSelection.c
r28955 r28958 38 38 /* free loaded images */ 39 39 void FreeImageSelection () { 40 if (image != NULL) free(image);40 if (image != NULL) FreeImages(image); 41 41 if (subset != NULL) free (subset); 42 42 image = NULL; -
trunk/Ohana/src/opihi/dvo/LoadImages.c
r27435 r28958 1 1 # include "dvoshell.h" 2 3 // XXX: Maybe make this a command line option 4 int dvoUseImageCache = 1; 5 6 static char *lastFilename = NULL; 7 static time_t lastModified = 0; 8 static Image *imageCache = NULL; 9 static off_t cacheNimage = 0; 10 11 static time_t getLastModified(char *filename); 2 12 3 13 Image *LoadImages (off_t *Nimage) { … … 12 22 catdir = GetCATDIR (); 13 23 sprintf (filename, "%s/Images.dat", catdir); 24 25 if (lastFilename) { 26 if (dvoUseImageCache && !strcmp(lastFilename, filename)) { 27 // Make sure the file hasn't changed since we loaded it 28 if (getLastModified(filename) == lastModified) { 29 *Nimage = cacheNimage; 30 return imageCache; 31 } 32 } 33 free(lastFilename); 34 lastFilename = NULL; 35 free(imageCache); 36 imageCache = NULL; 37 cacheNimage = 0; 38 lastModified = 0; 39 } 40 14 41 15 42 gfits_db_init (&db); … … 38 65 39 66 image = gfits_table_get_Image (&db.ftable, Nimage, &db.swapped); 67 if (dvoUseImageCache && image) { 68 cacheNimage = *Nimage; 69 imageCache = image; 70 lastFilename = strdup(filename); 71 lastModified = getLastModified(filename); 72 } 73 40 74 return (image); 41 75 } 76 77 static time_t getLastModified(char *filename) { 78 struct stat statbuf; 79 if (!stat(filename, &statbuf)) { 80 return statbuf.st_mtime; 81 } else { 82 return 0; 83 } 84 } 85 86 void FreeImages(Image *images) { 87 if (!dvoUseImageCache && (images != NULL)) { 88 free(images); 89 } else { 90 // defer free until next LoadImages with a different or modified Images.dat 91 } 92 } 93 -
trunk/Ohana/src/opihi/dvo/gimages.c
r28872 r28958 247 247 set_int_variable ("IMAGEphotcode:n", Nfound); 248 248 249 free(image);249 FreeImages (image); 250 250 free (subset); 251 251 -
trunk/Ohana/src/opihi/dvo/images.c
r27530 r28958 319 319 free (Xvec.elements.Flt); 320 320 free (Yvec.elements.Flt); 321 free(image);321 FreeImages (image); 322 322 return (TRUE); 323 323 -
trunk/Ohana/src/opihi/dvo/imdense.c
r27435 r28958 70 70 free (Xvec.elements.Flt); 71 71 free (Yvec.elements.Flt); 72 free(image);72 FreeImages (image); 73 73 return (TRUE); 74 74 -
trunk/Ohana/src/opihi/dvo/imextract.c
r27587 r28958 137 137 138 138 // free (subset); 139 free(image);139 FreeImages (image); 140 140 141 141 if (vec) free (vec); -
trunk/Ohana/src/opihi/include/dvoshell.h
r28955 r28958 302 302 int InitPhotcodes PROTO((void)); 303 303 Image *LoadImages PROTO((off_t *Nimage)); 304 void FreeImages PROTO((Image *images)); 304 305 Image *MatchImage PROTO((unsigned int time, short int source, unsigned int imageID)); 305 306 Coords *MatchMosaic PROTO((unsigned int time, short int source));
Note:
See TracChangeset
for help on using the changeset viewer.
