Skip to content

Commit

Permalink
Add Zlib::ZStream#avail_out=
Browse files Browse the repository at this point in the history
More work on issue rubinius#1561
  • Loading branch information
IPGlider committed May 15, 2012
1 parent a00455a commit 17e8c06
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/zlib.rb.ffi
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,27 @@ module Zlib
self[:avail_out]
end

def avail_out=(size)
raise ArgumentError, "negative string size (or size too big)" if size < 0

return size if size == self[:avail_out]

if @output.nil?
@output = ''
@next_out = FFI::MemoryPointer.new(size) if @next_out.nil?
@next_out.write_string("\000" * size)
else
buf = @next_out.read_string(@next_out.total - self[:avail_out])
@next_out.free
@next_out = FFI::MemoryPointer.new(buf.size + size)
@next_out.write_string(buf)
end

self[:next_out] = @next_out

self[:avail_out] = size
end

def closing?
@flags & CLOSING == CLOSING
end
Expand Down

0 comments on commit 17e8c06

Please sign in to comment.