diff options
author | Thomas White <taw@physics.org> | 2010-01-19 13:10:49 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2010-01-19 13:10:49 +0100 |
commit | 6de3c753b1531edb981e8ab8f709c60bf30bcfab (patch) | |
tree | 5e727a8d339f50f555e4f2c833e5ebcf406501a9 /src | |
parent | 56b1c4c6dfdb8fac6ddcc80178f1fd5dc87e14a4 (diff) |
Avoid array problems with hit finder
Diffstat (limited to 'src')
-rw-r--r-- | src/peaks.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/peaks.c b/src/peaks.c index 19ed28b8..6ded5a22 100644 --- a/src/peaks.c +++ b/src/peaks.c @@ -26,6 +26,7 @@ #define PEAK_WINDOW_SIZE (10) +#define MAX_PEAKS (2048) static int in_streak(int x, int y) { @@ -48,7 +49,7 @@ int image_fom(struct image *image) int x, y; int integr, n; float fintegr, mean, sd, th; - struct peak peaks[1024]; + struct peak peaks[MAX_PEAKS]; int i, n_peaks, n_nearby, n_valid; /* Measure mean */ @@ -104,16 +105,18 @@ int image_fom(struct image *image) val = image->data[x+image->height*y]; if ( val > th ) { - peaks[n_peaks].x = x; - peaks[n_peaks].y = y; - peaks[n_peaks].i = val; - peaks[n_peaks].invalid = 0; - n_peaks++; + if ( n_peaks < MAX_PEAKS ) { + peaks[n_peaks].x = x; + peaks[n_peaks].y = y; + peaks[n_peaks].i = val; + peaks[n_peaks].invalid = 0; + n_peaks++; + } } } } - + if ( n_peaks < 1 ) return 0; do { int max, max_i = -1; |