aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libcrystfel/src/reflist-utils.c28
-rw-r--r--libcrystfel/src/reflist-utils.h6
-rw-r--r--src/merge.c15
-rw-r--r--src/partialator.c6
-rw-r--r--src/scaling.c2
5 files changed, 51 insertions, 6 deletions
diff --git a/libcrystfel/src/reflist-utils.c b/libcrystfel/src/reflist-utils.c
index 54c467b3..70548994 100644
--- a/libcrystfel/src/reflist-utils.c
+++ b/libcrystfel/src/reflist-utils.c
@@ -3,11 +3,11 @@
*
* Utilities to complement the core reflist.c
*
- * Copyright © 2012-2017 Deutsches Elektronen-Synchrotron DESY,
+ * Copyright © 2012-2018 Deutsches Elektronen-Synchrotron DESY,
* a research centre of the Helmholtz Association.
*
* Authors:
- * 2011-2017 Thomas White <taw@physics.org>
+ * 2011-2018 Thomas White <taw@physics.org>
* 2014 Valerio Mariani
*
* This file is part of CrystFEL.
@@ -648,6 +648,30 @@ RefList *copy_reflist(RefList *list)
}
+/**
+ * free_contribs:
+ * @list: A %RefList
+ *
+ * Goes through @list and frees all the reflection contribution structures.
+ **/
+void free_contribs(RefList *list)
+{
+ Reflection *refl;
+ RefListIterator *iter;
+
+ for ( refl = first_refl(list, &iter);
+ refl != NULL;
+ refl = next_refl(refl, iter) )
+ {
+ struct reflection_contributions *c;
+ c = get_contributions(refl);
+ free(c->contribs);
+ free(c->contrib_crystals);
+ free(c);
+ }
+}
+
+
static char *full_command_line(int argc, char *argv[])
{
int i;
diff --git a/libcrystfel/src/reflist-utils.h b/libcrystfel/src/reflist-utils.h
index f64e9f51..c955491a 100644
--- a/libcrystfel/src/reflist-utils.h
+++ b/libcrystfel/src/reflist-utils.h
@@ -3,11 +3,11 @@
*
* Utilities to complement the core reflist.c
*
- * Copyright © 2012-2017 Deutsches Elektronen-Synchrotron DESY,
+ * Copyright © 2012-2018 Deutsches Elektronen-Synchrotron DESY,
* a research centre of the Helmholtz Association.
*
* Authors:
- * 2011-2017 Thomas White <taw@physics.org>
+ * 2011-2018 Thomas White <taw@physics.org>
* 2014 Valerio Mariani
*
* This file is part of CrystFEL.
@@ -69,6 +69,8 @@ extern RefList *res_cutoff(RefList *list, UnitCell *cell,
extern RefList *copy_reflist(RefList *list);
+extern void free_contribs(RefList *list);
+
extern void reflist_add_command_and_version(RefList *list,
int argcv, char *argv[]);
diff --git a/src/merge.c b/src/merge.c
index 3b850c30..9d36a359 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -3,11 +3,11 @@
*
* Parallel weighted merging of intensities
*
- * Copyright © 2012-2015 Deutsches Elektronen-Synchrotron DESY,
+ * Copyright © 2012-2018 Deutsches Elektronen-Synchrotron DESY,
* a research centre of the Helmholtz Association.
*
* Authors:
- * 2010-2015 Thomas White <taw@physics.org>
+ * 2010-2018 Thomas White <taw@physics.org>
*
* This file is part of CrystFEL.
*
@@ -46,6 +46,7 @@
#include "cell.h"
#include "utils.h"
#include "reflist.h"
+#include "reflist-utils.h"
#include "cell-utils.h"
@@ -319,6 +320,16 @@ RefList *merge_intensities(Crystal **crystals, int n, int n_threads,
get_indices(refl, &h, &k, &l);
r2 = add_refl(full2, h, k, l);
copy_data(r2, refl);
+
+ } else {
+
+ /* We do not need the contribution list any more */
+ struct reflection_contributions *c;
+ c = get_contributions(refl);
+ free(c->contribs);
+ free(c->contrib_crystals);
+ free(c);
+
}
}
diff --git a/src/partialator.c b/src/partialator.c
index fa07eab7..78b7173b 100644
--- a/src/partialator.c
+++ b/src/partialator.c
@@ -199,12 +199,14 @@ static void write_split(Crystal **crystals, int n_crystals, const char *outfile,
STATUS("Writing two-way split to %s ", tmp);
write_reflist_2(tmp, split, sym);
+ free_contribs(split);
reflist_free(split);
snprintf(tmp, 1024, "%s2", outfile);
split = merge_intensities(crystals2, n_crystals2, nthreads,
min_measurements, push_res, 1);
STATUS("and %s\n", tmp);
write_reflist_2(tmp, split, sym);
+ free_contribs(split);
reflist_free(split);
}
@@ -291,6 +293,7 @@ static void write_custom_split(struct custom_split *csplit, int dsn,
split = merge_intensities(crystalsn, n_crystalsn, nthreads,
min_measurements, push_res, 1);
write_reflist_2(tmp, split, sym);
+ free_contribs(split);
reflist_free(split);
write_split(crystalsn, n_crystalsn, tmp, nthreads, pmodel,
@@ -1436,6 +1439,7 @@ int main(int argc, char *argv[])
/* Create new reference if needed */
if ( reference == NULL ) {
+ free_contribs(full);
reflist_free(full);
if ( !no_scale ) {
scale_all(crystals, n_crystals, nthreads,
@@ -1484,6 +1488,7 @@ int main(int argc, char *argv[])
/* Final merge */
STATUS("Final merge...\n");
if ( reference == NULL ) {
+ free_contribs(full);
reflist_free(full);
if ( !no_scale ) {
scale_all(crystals, n_crystals, nthreads, scaleflags);
@@ -1530,6 +1535,7 @@ int main(int argc, char *argv[])
reflist_free(crystal_get_reflections(crystals[i]));
crystal_free(crystals[i]);
}
+ free_contribs(full);
reflist_free(full);
free_symoplist(sym);
free(outfile);
diff --git a/src/scaling.c b/src/scaling.c
index 21bd0db2..68456900 100644
--- a/src/scaling.c
+++ b/src/scaling.c
@@ -46,6 +46,7 @@
#include "cell.h"
#include "cell-utils.h"
#include "scaling.h"
+#include "reflist-utils.h"
struct scale_args
@@ -166,6 +167,7 @@ void scale_all(Crystal **crystals, int n_crystals, int nthreads, int scaleflags)
meanB /= n_crystals;
STATUS("Mean B = %e\n", meanB);
+ free_contribs(full);
reflist_free(full);
niter++;