aboutsummaryrefslogtreecommitdiff
path: root/julia
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2024-02-21 14:53:09 +0100
committerThomas White <taw@physics.org>2024-02-21 14:53:09 +0100
commitfa7c1e4aa507489f1c5ae9d9c107beaca5a705d3 (patch)
tree90db1a264dd5d2f96bfb66a6653a9fabfe08d934 /julia
parentfc78b43a4057be4216b55c3f8999f8f4296c04d9 (diff)
Julia: Set finalizers for RefList and Crystal when taken from image
Diffstat (limited to 'julia')
-rw-r--r--julia/CrystFEL/src/image.jl7
1 files changed, 6 insertions, 1 deletions
diff --git a/julia/CrystFEL/src/image.jl b/julia/CrystFEL/src/image.jl
index 33af3252..4090dc61 100644
--- a/julia/CrystFEL/src/image.jl
+++ b/julia/CrystFEL/src/image.jl
@@ -86,11 +86,16 @@ function makecrystallist(image, listptr, n)
else
reflist = RefList{UnmergedReflection}(pairptr.reflist, SymOpList("1"))
pairptr.owns_reflist = 0
+ finalizer(reflist) do x
+ @ccall libcrystfel.reflist_free(x.internalptr::Ptr{InternalRefList})::Cvoid
+ end
end
push!(crystals, (crystal=cr, reflections=reflist))
pairptr.owns_crystal = 0
unsafe_store!(listptr, pairptr, i)
- # We are now responsible for freeing the Crystal and RefList
+ finalizer(cr) do x
+ @ccall libcrystfel.crystal_free(x.internalptr::Ptr{InternalCrystal})::Cvoid
+ end
end
image.crystals = map(x->x.crystal, crystals)