Skip to content

Commit

Permalink
Fix 1.10/1.11 compat issue
Browse files Browse the repository at this point in the history
  • Loading branch information
quinnj committed Sep 26, 2024
1 parent 6d4db2a commit 4ebb277
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/Streams.jl
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,20 @@ end

_alloc_request(buf::IOBuffer, recommended_size::UInt) = Base.alloc_request(buf, recommended_size)

function _alloc_request(buffer::Base.GenericIOBuffer, recommended_size::UInt)
Base.ensureroom(buffer, Int(recommended_size))
ptr = buffer.append ? buffer.size + 1 : buffer.ptr
nb = min(length(buffer.data)-buffer.offset, buffer.maxsize) + buffer.offset - ptr + 1
return (Ptr{Cvoid}(pointer(buffer.data, ptr)), nb)
@static if VERSION < v"1.11"
function _alloc_request(buffer::Base.GenericIOBuffer, recommended_size::UInt)
Base.ensureroom(buffer, Int(recommended_size))
ptr = buffer.append ? buffer.size + 1 : buffer.ptr
nb = min(length(buffer.data), buffer.maxsize) - ptr + 1
return (Ptr{Cvoid}(pointer(buffer.data, ptr)), nb)
end
else
function _alloc_request(buffer::Base.GenericIOBuffer, recommended_size::UInt)
Base.ensureroom(buffer, Int(recommended_size))
ptr = buffer.append ? buffer.size + 1 : buffer.ptr
nb = min(length(buffer.data)-buffer.offset, buffer.maxsize) + buffer.offset - ptr + 1
return (Ptr{Cvoid}(pointer(buffer.data, ptr)), nb)
end
end

function Base.readbytes!(http::Stream, buf::Base.GenericIOBuffer, n=bytesavailable(http))
Expand Down

0 comments on commit 4ebb277

Please sign in to comment.