aboutsummaryrefslogtreecommitdiff
path: root/src/detector.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2010-06-11 16:06:04 -0700
committerThomas White <taw@bitwiz.org.uk>2010-06-11 16:06:04 -0700
commitd88796d69537a2b720e84dbad6fb4d501a59fbd1 (patch)
treedde75312bfe9aedc6508564748065df1e080a917 /src/detector.c
parent0a8c401e861e67c5dd6adfd1318b7c26d77edf70 (diff)
Set det->n_panels
Diffstat (limited to 'src/detector.c')
-rw-r--r--src/detector.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/detector.c b/src/detector.c
index 988c77fb..d0b03877 100644
--- a/src/detector.c
+++ b/src/detector.c
@@ -166,7 +166,6 @@ struct detector *get_detector_geometry(const char *filename)
struct detector *det;
char *rval;
char **bits;
- int n_panels = -1;
int i;
fh = fopen(filename, "r");
@@ -177,6 +176,7 @@ struct detector *get_detector_geometry(const char *filename)
fclose(fh);
return NULL;
}
+ det->n_panels = -1;
do {
@@ -195,14 +195,15 @@ struct detector *get_detector_geometry(const char *filename)
if ( bits[1][0] != '=' ) continue;
if ( strcmp(bits[0], "n_panels") == 0 ) {
- if ( n_panels != -1 ) {
+ if ( det->n_panels != -1 ) {
ERROR("Duplicate n_panels statement.\n");
fclose(fh);
free(det);
return NULL;
}
- n_panels = atoi(bits[2]);
- det->panels = malloc(n_panels * sizeof(struct panel));
+ det->n_panels = atoi(bits[2]);
+ det->panels = malloc(det->n_panels
+ * sizeof(struct panel));
continue;
}
@@ -232,7 +233,7 @@ struct detector *get_detector_geometry(const char *filename)
} while ( rval != NULL );
- if ( n_panels == -1 ) {
+ if ( det->n_panels == -1 ) {
ERROR("No panel descriptions in geometry file.\n");
fclose(fh);
free(det->panels);
@@ -240,7 +241,7 @@ struct detector *get_detector_geometry(const char *filename)
return NULL;
}
- for ( i=0; i<n_panels; i++ ) {
+ for ( i=0; i<det->n_panels; i++ ) {
STATUS("Panel %i, min_x = %i\n", i, det->panels[i].min_x);
STATUS("Panel %i, max_x = %i\n", i, det->panels[i].max_x);
STATUS("Panel %i, min_y = %i\n", i, det->panels[i].min_y);