Skip to content

Commit

Permalink
Remove remaining uses of GC.@preserve
Browse files Browse the repository at this point in the history
  • Loading branch information
helgee committed Jul 28, 2021
1 parent 6225ea4 commit ee92451
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/cells.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ len(::Type{SpiceChar}, length) = length += 1
dim(::Type{T}) where {T} = 1
dim(::Type{SpiceChar}) = 2

data_ptr(::Type{SpiceChar}, data, length) = GC.@preserve data pointer(data, CTRLSZ * length + 1)
data_ptr(::Type{T}, data, _) where {T} = GC.@preserve data pointer(data, CTRLSZ + 1)
data_ptr(::Type{SpiceChar}, data, length) = pointer(data, CTRLSZ * length + 1)
data_ptr(::Type{T}, data, _) where {T} = pointer(data, CTRLSZ + 1)

mutable struct SpiceCell{S, T, N} <: AbstractArray{T, 1}
data::Array{S, N}
Expand All @@ -47,7 +47,7 @@ mutable struct SpiceCell{S, T, N} <: AbstractArray{T, 1}
cell = Cell{T}(length, size)
data = init_data(T, size, length)
self = new{T, itertype(T), dim(T)}(data, cell)
self.cell.base = GC.@preserve self pointer(self.data, 1)
self.cell.base = pointer(self.data, 1)
self.cell.data = data_ptr(T, self.data, length)
self
end
Expand Down Expand Up @@ -179,7 +179,7 @@ Duplicate the SpiceCell `cell`.
"""
function Base.copy(cell::SpiceCell{T}) where {T}
cell_copy = deepcopy(cell)
cell_copy.cell.base = GC.@preserve cell_copy pointer(cell_copy.data, 1)
cell_copy.cell.base = pointer(cell_copy.data, 1)
cell_copy.cell.data = data_ptr(T, cell_copy.data, length)
cell_copy
end
Expand Down
2 changes: 1 addition & 1 deletion src/t.jl
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ version string.
"""
function tkvrsn(item=:TOOLKIT)
out = ccall((:tkvrsn_c, libcspice), Cstring, (Cstring,), string(item))
GC.@preserve out unsafe_string(pointer(out))
return unsafe_string(out)
end

"""
Expand Down

0 comments on commit ee92451

Please sign in to comment.