diff options
author | Thomas White <taw@physics.org> | 2010-01-19 17:24:57 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2010-01-19 17:24:57 +0100 |
commit | b53c57478e47dba3027ca594543cbaa8a32fb103 (patch) | |
tree | be6393e447ca9e07c26342bfc6cb6a5147a7eb14 | |
parent | 6de3c753b1531edb981e8ab8f709c60bf30bcfab (diff) |
Fix more carnage
Allocate this big block from the heap to avoid stack corruption
-rw-r--r-- | src/peaks.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/peaks.c b/src/peaks.c index 6ded5a22..d5936b17 100644 --- a/src/peaks.c +++ b/src/peaks.c @@ -49,9 +49,11 @@ int image_fom(struct image *image) int x, y; int integr, n; float fintegr, mean, sd, th; - struct peak peaks[MAX_PEAKS]; + struct peak *peaks; int i, n_peaks, n_nearby, n_valid; + peaks = malloc(MAX_PEAKS * sizeof(struct peak)); + /* Measure mean */ integr = 0; n = 0; @@ -117,6 +119,7 @@ int image_fom(struct image *image) } } if ( n_peaks < 1 ) return 0; + do { int max, max_i = -1; @@ -147,7 +150,8 @@ int image_fom(struct image *image) } } if ( adjacent < 1 ) { - peaks[i].invalid = 1; + peaks[max_i].invalid = 1; + /* If invalidated, don't remove nearby peaks */ continue; } @@ -178,6 +182,8 @@ int image_fom(struct image *image) n_valid++; } + free(peaks); + return n_valid; } |