Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default offset argument for mmap / anonymous does not work #31714

Open
chethega opened this issue Apr 13, 2019 · 0 comments
Open

default offset argument for mmap / anonymous does not work #31714

chethega opened this issue Apr 13, 2019 · 0 comments

Comments

@chethega
Copy link
Contributor

Small convenience issue:

julia> using Mmap

julia> anon = Mmap.Anonymous()
Mmap.Anonymous("", false, true)

julia> Mmap.mmap(anon, Vector{UInt8}, (4,))
ERROR: MethodError: no method matching position(::Mmap.Anonymous)
Closest candidates are:
  position(::Base.SecretBuffer) at secretbuffer.jl:154
  position(::Base.Filesystem.File) at filesystem.jl:225
  position(::Base.Libc.FILE) at libc.jl:101
  ...
Stacktrace:
 [1] mmap(::Mmap.Anonymous, ::Type{Array{UInt8,1}}, ::Tuple{Int64}) at /build/julia/src/julia-1.1.0/usr/share/julia/stdlib/v1.1/Mmap/src/Mmap.jl:186
 [2] top-level scope at none:0

julia> Mmap.mmap(anon, Vector{UInt8}, (4,), 0)
4-element Array{UInt8,1}:
 0x00
 0x00
 0x00
 0x00

I'd guess we should either implement position(::Mmap.Anonymous)=0 or change the default argument, like e.g.

function mmap(io::IO,
              ::Type{Array{T,N}}=Vector{UInt8},
              dims::NTuple{N,Integer}=(div(filesize(io)-position(io),sizeof(T)),),
              offset::Integer=(io isa Anonymous ? 0 : position(io)); grow::Bool=true, shared::Bool=true) where {T,N}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant