Skip to content

Commit d4a8c92

Browse files
committed
Use Base.alloc_request instead of implementing it directly
There is slightly better error handling in this function, which avoids relying as directly on implementation details of IOBuffer
1 parent 040cf0a commit d4a8c92

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Connections.jl

+3-2
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,10 @@ function read_to_buffer(c::Connection, sizehint=4096)
224224
# Read from stream into buffer.
225225
n = min(sizehint, bytesavailable(c.io))
226226
buf = c.buffer
227-
Base.ensureroom(buf, n)
228-
GC.@preserve buf unsafe_read(c.io, pointer(buf.data, buf.size + 1), n)
227+
p, n = Base.alloc_request(buf, UInt(n))
228+
GC.@preserve buf unsafe_read(c.io, p, min(n, bytesavailable(c.io)))
229229
buf.size += n
230+
nothing
230231
end
231232

232233
"""

0 commit comments

Comments
 (0)