Skip to content

Commit

Permalink
GC_preserve coldefs in create_(binary/ascii)_table (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub authored Jul 6, 2024
1 parent faa9478 commit 1a398fb
Showing 1 changed file with 29 additions and 27 deletions.
56 changes: 29 additions & 27 deletions src/CFITSIO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2171,35 +2171,37 @@ for (a, b) in ((:fits_create_binary_tbl, 2), (:fits_create_ascii_tbl, 1))

# get length and convert coldefs to three arrays of Ptr{Uint8}
ntype = length(coldefs)
ttype = [pointer(x[1]) for x in coldefs]
tform = [pointer(x[2]) for x in coldefs]
tunit = [pointer(x[3]) for x in coldefs]
status = Ref{Cint}(0)
GC.@preserve coldefs begin
ttype = [pointer(x[1]) for x in coldefs]
tform = [pointer(x[2]) for x in coldefs]
tunit = [pointer(x[3]) for x in coldefs]
status = Ref{Cint}(0)

ccall(
("ffcrtb", libcfitsio),
Cint,
(
Ptr{Cvoid},
Cint,
Int64,
ccall(
("ffcrtb", libcfitsio),
Cint,
Ptr{Ptr{UInt8}},
Ptr{Ptr{UInt8}},
Ptr{Ptr{UInt8}},
Ptr{UInt8},
Ref{Cint},
),
f.ptr,
$b,
numrows,
ntype,
ttype,
tform,
tunit,
extname,
status,
)
(
Ptr{Cvoid},
Cint,
Int64,
Cint,
Ptr{Ptr{UInt8}},
Ptr{Ptr{UInt8}},
Ptr{Ptr{UInt8}},
Ptr{UInt8},
Ref{Cint},
),
f.ptr,
$b,
numrows,
ntype,
ttype,
tform,
tunit,
extname,
status,
)
end
fits_assert_ok(status[])
end
end
Expand Down

0 comments on commit 1a398fb

Please sign in to comment.