Skip to content

Commit

Permalink
Fix 32bit tests and remove potentially unsafe code
Browse files Browse the repository at this point in the history
  • Loading branch information
helgee committed Mar 9, 2019
1 parent c404a33 commit 7cd7126
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/SPICE.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function __init__()
gfrepi_ptr[] = Libdl.dlsym(lib, :gfrepi_c)
gfrepu_ptr[] = Libdl.dlsym(lib, :gfrepu_c)
gfrepf_ptr[] = Libdl.dlsym(lib, :gfrepf_c)
nothing
end

struct SpiceError <: Exception
Expand Down
15 changes: 4 additions & 11 deletions src/cells.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ 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)
base = pointer(self.data, 1)
data = pointer(self.data, CTRLSZ + 1)
self.cell.base = pointer(self.data, 1)
self.cell.data = data_ptr(T, self.data, length)
self
Expand Down Expand Up @@ -180,15 +178,10 @@ size(cell::SpiceCell) = (card(cell),)
Duplicate the SpiceCell `cell`.
"""
function Base.copy(cell::SpiceCell{T}) where {T}
copy = SpiceCell{T}(cell.cell.size)
ccall((:copy_c, libcspice), Cvoid, (Ref{Cell{T}}, Ref{Cell{T}}), cell.cell, copy.cell)
copy
end

function Base.copy(cell::SpiceCharCell)
copy = SpiceCharCell(cell.cell.size, cell.cell.length)
ccall((:copy_c, libcspice), Cvoid, (Ref{Cell{SpiceChar}}, Ref{Cell{SpiceChar}}), cell.cell, copy.cell)
copy
cell_copy = deepcopy(cell)
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
4 changes: 2 additions & 2 deletions test/g.jl
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,8 @@ using Random: randstring
beg, stop = wnfetd(result, 2)
begstr = timout(beg, "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND", 80)
endstr = timout(stop, "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND", 80)
@test begstr == "2007-SEP-23 09:46:39.606982 (TDB)"
@test endstr == "2007-SEP-23 09:46:39.606982 (TDB)"
@test startswith(begstr, "2007-SEP-23 09:46:39.60698")
@test startswith(endstr, "2007-SEP-23 09:46:39.60698")
finally
kclear()
end
Expand Down

0 comments on commit 7cd7126

Please sign in to comment.