From d19afd914f7844945b0a44ef2fcb0def29f92046 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 26 Jun 2015 15:49:31 +0200 Subject: Fix prediction refinement memory leaks --- libcrystfel/src/predict-refine.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'libcrystfel/src/predict-refine.c') diff --git a/libcrystfel/src/predict-refine.c b/libcrystfel/src/predict-refine.c index 2d845feb..6ef31805 100644 --- a/libcrystfel/src/predict-refine.c +++ b/libcrystfel/src/predict-refine.c @@ -211,6 +211,7 @@ static int pair_peaks(struct image *image, Crystal *cr, { int i; int n_acc = 0; + int n_final; int n = 0; double ax, ay, az; double bx, by, bz; @@ -291,9 +292,6 @@ static int pair_peaks(struct image *image, Crystal *cr, rps[n_acc] = rps[i]; rps[n_acc].refl = reflection_new(h, k, l); copy_data(rps[n_acc].refl, refl); - if ( reflist != NULL ) { - add_refl_to_list(rps[n_acc].refl, reflist); - } n_acc++; } @@ -301,9 +299,21 @@ static int pair_peaks(struct image *image, Crystal *cr, /* Sort the pairings by excitation error and look for a transition * between good pairings and outliers */ - n_acc = check_outlier_transition(rps, n_acc, image->det); + n_final = check_outlier_transition(rps, n_acc, image->det); + + /* Add the final accepted reflections to the caller's list */ + if ( reflist != NULL ) { + for ( i=0; i