From 2977589d2201ade9aa02289a54359288af2ff16e Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 27 May 2013 17:24:58 +0200 Subject: Fix ReAx stack corruption --- libcrystfel/src/index.c | 3 ++- libcrystfel/src/reax.c | 13 +++++++++---- libcrystfel/src/reax.h | 4 ++-- 3 files changed, 13 insertions(+), 7 deletions(-) (limited to 'libcrystfel') diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c index bd187cf5..8307778d 100644 --- a/libcrystfel/src/index.c +++ b/libcrystfel/src/index.c @@ -214,6 +214,7 @@ static int try_indexer(struct image *image, IndexingMethod indm, switch ( indm & INDEXING_METHOD_MASK ) { case INDEXING_NONE : + return 0; break; case INDEXING_DIRAX : @@ -229,7 +230,7 @@ static int try_indexer(struct image *image, IndexingMethod indm, break; case INDEXING_REAX : - return reax_index(image, ipriv); + return reax_index(ipriv, image); break; case INDEXING_GRAINSPOTTER : diff --git a/libcrystfel/src/reax.c b/libcrystfel/src/reax.c index 112d91fa..2a599b40 100644 --- a/libcrystfel/src/reax.c +++ b/libcrystfel/src/reax.c @@ -48,6 +48,7 @@ #include "cell.h" #include "cell-utils.h" #include "index.h" +#include "reax.h" /* Minimum number of standard deviations above the mean a peak must be in the @@ -109,6 +110,7 @@ struct reax_private struct dvec *directions; int n_dir; double angular_inc; + UnitCell *cell; double *fft_in; fftw_complex *fft_out; @@ -1040,7 +1042,7 @@ static void assemble_cells_from_candidates(struct image *image, } -void reax_index(IndexingPrivate *pp, struct image *image, UnitCell *cell) +int reax_index(IndexingPrivate *pp, struct image *image) { struct reax_private *p; double *fft_in; @@ -1060,10 +1062,10 @@ void reax_index(IndexingPrivate *pp, struct image *image, UnitCell *cell) if ( pmax < 1e4 ) { fftw_free(fft_in); fftw_free(fft_out); - return; + return 0; } - s = search_all_axes(cell, pmax); + s = search_all_axes(p->cell, pmax); find_candidates(p, image->features, pmax, fft_in, fft_out, s, NULL, image->det); @@ -1071,7 +1073,7 @@ void reax_index(IndexingPrivate *pp, struct image *image, UnitCell *cell) // fft_in, fft_out, p->plan, smin, smax, // image->det, p); - assemble_cells_from_candidates(image, s, cell, p); + assemble_cells_from_candidates(image, s, p->cell, p); for ( i=0; in_search; i++ ) { free(s->search[i].cand); @@ -1080,6 +1082,7 @@ void reax_index(IndexingPrivate *pp, struct image *image, UnitCell *cell) free(s); fftw_free(fft_in); fftw_free(fft_out); + return 1; } @@ -1099,6 +1102,8 @@ IndexingPrivate *reax_prepare(IndexingMethod *indm, UnitCell *cell, p = calloc(1, sizeof(*p)); if ( p == NULL ) return NULL; + p->cell = cell; + /* Flags that ReAx knows about */ *indm &= INDEXING_METHOD_MASK | INDEXING_CHECK_PEAKS; diff --git a/libcrystfel/src/reax.h b/libcrystfel/src/reax.h index f1c57e6c..1b96bd5d 100644 --- a/libcrystfel/src/reax.h +++ b/libcrystfel/src/reax.h @@ -46,7 +46,7 @@ extern IndexingPrivate *reax_prepare(IndexingMethod *indm, UnitCell *cell, extern void reax_cleanup(IndexingPrivate *pp); -extern int reax_index(struct image *image, IndexingPrivate *p); +extern int reax_index(IndexingPrivate *pp, struct image *image); #else /* HAVE_FFTW */ @@ -61,7 +61,7 @@ static void reax_cleanup(IndexingPrivate *pp) { } -static int reax_index(struct image *image, IndexingPrivate *p) +static int reax_index(IndexingPrivate *pp, struct image *image); { } -- cgit v1.2.3