diff options
author | Thomas White <taw@physics.org> | 2024-01-21 12:14:27 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2024-02-06 16:59:35 +0100 |
commit | 85a57decf6cafc353b792cd52f476eed4ade3915 (patch) | |
tree | 351c20c0afd632fffe84e8db5417c09d6ac52bac /julia | |
parent | f5925d65fe5d2fe7bf0293dc43e32ee48d8d4014 (diff) |
Julia: push!(image, crystal): Mark crystal as not to be freed
The crystal must also be added to the image's list, so that it doesn't
get GCed while the image is still around.
Diffstat (limited to 'julia')
-rw-r--r-- | julia/CrystFEL/src/image.jl | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/julia/CrystFEL/src/image.jl b/julia/CrystFEL/src/image.jl index e11b41c1..020117e7 100644 --- a/julia/CrystFEL/src/image.jl +++ b/julia/CrystFEL/src/image.jl @@ -205,9 +205,15 @@ end function Base.push!(image::Image, cr::Crystal) - ccall((:image_add_crystal, libcrystfel), - Cvoid, (Ptr{InternalImage},Ptr{InternalCrystal}), - image.internalptr, cr.internalptr) + @ccall libcrystfel.image_add_crystal(image.internalptr::Ptr{InternalImage}, + cr.internalptr::Ptr{InternalCrystal})::Cvoid + + idata = unsafe_load(image.internalptr) + ncryst = idata.n_crystals + pairptr = unsafe_load(idata.crystal_refls, ncryst) + pairptr.owns_crystal = 0 + unsafe_store!(idata.crystal_refls, pairptr, ncryst) + push!(getfield(image, :crystals), cr) end |