diff options
author | Thomas White <taw@bitwiz.org.uk> | 2011-02-18 16:31:40 -0800 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:15 +0100 |
commit | 6fb8d4b727b82f32168f9ba44a1d4f5c5033d181 (patch) | |
tree | 77037316f3f13b257d81670b969aac4d3274fdbf /src/detector.c | |
parent | 83af8912dcdc58423298e50441617ebce26891a6 (diff) |
Introduce 'geomatic'
Diffstat (limited to 'src/detector.c')
-rw-r--r-- | src/detector.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/detector.c b/src/detector.c index af7b0c0d..154fe660 100644 --- a/src/detector.c +++ b/src/detector.c @@ -214,6 +214,7 @@ struct detector *get_detector_geometry(const char *filename) return NULL; } det->n_panels = -1; + det->panels = NULL; do { @@ -339,7 +340,7 @@ struct detector *get_detector_geometry(const char *filename) if ( det->n_panels == -1 ) { ERROR("No panel descriptions in geometry file.\n"); fclose(fh); - free(det->panels); + if ( det->panels != NULL ) free(det->panels); free(det); return NULL; } @@ -349,56 +350,46 @@ struct detector *get_detector_geometry(const char *filename) max_y = 0; for ( i=0; i<det->n_panels; i++ ) { - STATUS("Panel %i, min_x = %i\n", i, det->panels[i].min_x); if ( det->panels[i].min_x == -1 ) { ERROR("Please specify the minimum x coordinate for" " panel %i\n", i); reject = 1; } - STATUS("Panel %i, max_x = %i\n", i, det->panels[i].max_x); if ( det->panels[i].max_x == -1 ) { ERROR("Please specify the maximum x coordinate for" " panel %i\n", i); reject = 1; } - STATUS("Panel %i, min_y = %i\n", i, det->panels[i].min_y); if ( det->panels[i].min_y == -1 ) { ERROR("Please specify the minimum y coordinate for" " panel %i\n", i); reject = 1; } - STATUS("Panel %i, max_y = %i\n", i, det->panels[i].max_y); if ( det->panels[i].max_y == -1 ) { ERROR("Please specify the maximum y coordinate for" " panel %i\n", i); reject = 1; } - STATUS("Panel %i, cx = %f\n", i, det->panels[i].cx); if ( det->panels[i].cx == -1 ) { ERROR("Please specify the centre x coordinate for" " panel %i\n", i); reject = 1; } - STATUS("Panel %i, cy = %f\n", i, det->panels[i].cy); if ( det->panels[i].cy == -1 ) { ERROR("Please specify the centre y coordinate for" " panel %i\n", i); reject = 1; } - STATUS("Panel %i, clen = %f\n", i, det->panels[i].clen); if ( det->panels[i].clen == -1 ) { ERROR("Please specify the camera length for" " panel %i\n", i); reject = 1; } - STATUS("Panel %i, res = %f\n", i, det->panels[i].res); if ( det->panels[i].res == -1 ) { ERROR("Please specify the resolution for" " panel %i\n", i); reject = 1; } - STATUS("Panel %i, badrow direction = %c\n", i, - det->panels[i].badrow); /* It's OK if the badrow direction is '0' */ /* It's not a problem if "no_index" is still zero */ /* The default peak_sep is OK (maybe) */ @@ -431,3 +422,10 @@ out: return det; } + + +void free_detector_geometry(struct detector *det) +{ + free(det->panels); + free(det); +} |