aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/indexamajig.c25
-rw-r--r--src/process_image.h2
2 files changed, 18 insertions, 9 deletions
diff --git a/src/indexamajig.c b/src/indexamajig.c
index d6ebe3ea..4a80e762 100644
--- a/src/indexamajig.c
+++ b/src/indexamajig.c
@@ -244,9 +244,19 @@ static void add_geom_beam_stuff_to_field_list(struct imagefile_field_list *copym
static struct spectrum *read_spectrum_fromfile(char *fn)
{
FILE *f;
+ struct spectrum *s;
+ int i;
+ double k, w;
+ double w_sum = 0;
+
f = fopen(fn, "r");
+ if ( f == NULL ) {
+ ERROR("Couldn't open '%s'\n", fn);
+ return NULL;
+ }
- struct spectrum *s = malloc(sizeof(struct spectrum));
+ s = malloc(sizeof(struct spectrum));
+ if ( s == NULL ) return NULL;
if ( fscanf(f, "%d", &s->n) == EOF ) {
return NULL;
@@ -268,15 +278,14 @@ static struct spectrum *read_spectrum_fromfile(char *fn)
return NULL;
}
- int i;
- double k, w;
- double w_sum = 0;
- for ( i = 0; i < s->n; i++ ) {
- if (fscanf(f, "%lf %lf", &k, &w) != EOF) {
+ for ( i=0; i<s->n; i++ ) {
+ if ( fscanf(f, "%lf %lf", &k, &w) != EOF ) {
s->ks[i] = ph_eV_to_k(k);
s->weights[i] = w;
w_sum += w;
- } else break;
+ } else {
+ break;
+ }
}
if ( i < s->n - 1 ) {
@@ -284,7 +293,7 @@ static struct spectrum *read_spectrum_fromfile(char *fn)
return NULL;
}
- for ( i = 0; i < s->n; i++ ) {
+ for ( i=0; i<s->n; i++ ) {
s->weights[i] /= w_sum;
}
diff --git a/src/process_image.h b/src/process_image.h
index 14b2aae8..d4dcbf04 100644
--- a/src/process_image.h
+++ b/src/process_image.h
@@ -110,7 +110,7 @@ struct index_args
int overpredict;
int profile; /* Whether or not to do wall clock profiling */
struct taketwo_options taketwo_opts;
- struct xgandalf_options xgandalf_opts;
+ struct xgandalf_options xgandalf_opts;
struct felix_options felix_opts;
struct spectrum *spectrum;
};