diff --git a/Project.toml b/Project.toml index 3c4bfbd..40b9223 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ManualMemory" uuid = "d125e4d3-2237-4719-b19c-fa641b8a4667" authors = ["chriselrod and contributors"] -version = "0.1.4" +version = "0.1.5" [compat] julia = "1.5" diff --git a/src/ManualMemory.jl b/src/ManualMemory.jl index 861255c..5f41426 100644 --- a/src/ManualMemory.jl +++ b/src/ManualMemory.jl @@ -50,7 +50,12 @@ end @inline store!(p::Ptr{T}, v) where {T} = store!(p, convert(T, v)) -mutable struct Reference{T}; data::T; end +mutable struct Reference{T} + data::T + + Reference{T}() where {T} = new() + Reference{T}(x) where {T} = new(x) +end @inline load(p::Ptr{Reference{T}}) where {T} = getfield(ccall(:jl_value_ptr, Ref{Reference{T}}, (Ptr{Cvoid},), unsafe_load(Base.unsafe_convert(Ptr{Ptr{Cvoid}}, p))), :data) @inline dereference(r::Reference) = getfield(r, :data) @inline dereference(x) = x