Skip to content

Commit

Permalink
add back method for Vector{UInt8}
Browse files Browse the repository at this point in the history
  • Loading branch information
nhz2 committed May 30, 2024
1 parent 65e398a commit 552d6c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/memory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ struct Memory
size::UInt
end

function Memory(data::Vector{UInt8})
return Memory(pointer(data), sizeof(data))
end

@inline function Base.length(mem::Memory)
return mem.size
end
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ end
end

data = Vector{UInt8}(b"foobar")
GC.@preserve data let mem = TranscodingStreams.Memory(pointer(data), sizeof(data))
GC.@preserve data let mem = TranscodingStreams.Memory(data)
@test mem isa TranscodingStreams.Memory
@test mem.ptr == pointer(data)
@test mem.size == sizeof(data)
Expand Down

0 comments on commit 552d6c3

Please sign in to comment.