aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2024-01-18 17:55:45 +0100
committerThomas White <taw@physics.org>2024-02-06 16:59:35 +0100
commit1b4fdfa5cc1ab4fe9a1cdcbb0bf1602834eaec13 (patch)
tree03061175385337244c7605c5810db1d6affcd779 /libcrystfel/src
parentff89f33377133352838f27057525701e71c9df7c (diff)
Julia: MM semantics for Image.crystals
Diffstat (limited to 'libcrystfel/src')
-rw-r--r--libcrystfel/src/image.c10
-rw-r--r--libcrystfel/src/image.h2
2 files changed, 10 insertions, 2 deletions
diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c
index ab4518a9..e91c09d6 100644
--- a/libcrystfel/src/image.c
+++ b/libcrystfel/src/image.c
@@ -333,6 +333,8 @@ void image_add_crystal_refls(struct image *image,
crs[n].cr = cryst;
crs[n].refls = reflist;
+ crs[n].image_owns_crystal = 1;
+ crs[n].image_owns_refls = 1;
image->crystals = crs;
image->n_crystals = n+1;
}
@@ -373,8 +375,12 @@ void free_all_crystals(struct image *image)
int i;
if ( image->crystals == NULL ) return;
for ( i=0; i<image->n_crystals; i++ ) {
- crystal_free(image->crystals[i].cr);
- reflist_free(image->crystals[i].refls);
+ if ( image->crystals[i].image_owns_crystal ) {
+ crystal_free(image->crystals[i].cr);
+ }
+ if ( image->crystals[i].image_owns_refls ) {
+ reflist_free(image->crystals[i].refls);
+ }
}
cffree(image->crystals);
image->crystals = NULL;
diff --git a/libcrystfel/src/image.h b/libcrystfel/src/image.h
index 74ff6eee..3db7de18 100644
--- a/libcrystfel/src/image.h
+++ b/libcrystfel/src/image.h
@@ -114,6 +114,8 @@ struct crystal_refls
{
Crystal *cr;
RefList *refls;
+ int image_owns_crystal;
+ int image_owns_refls;
};
struct image