Skip to content

Commit

Permalink
Updated for Crystal 0.35.1
Browse files Browse the repository at this point in the history
  • Loading branch information
naqvis committed Jun 22, 2020
1 parent 5323ae6 commit adf3889
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions shard.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: lz4
version: 0.1.1
version: 0.1.2

authors:
- Ali Naqvi <syed.alinaqvi@gmail.com>
description: |
Crystal bindings to the LZ4 compression library.
crystal: 0.35.0
crystal: 0.35.1

license: MIT
2 changes: 1 addition & 1 deletion src/lz4.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require "semantic_version"

module Compress::LZ4
VERSION = "0.1.0"
VERSION = "0.1.2"

LZ4_VERSION = SemanticVersion.parse String.new(LibLZ4.version_string)
LZ4_VERSION_MINIMUM = SemanticVersion.parse("1.9.2")
Expand Down
6 changes: 2 additions & 4 deletions src/lz4/writer.cr
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,23 @@ class Compress::LZ4::Writer < IO
end

# See `IO#write`.
def write(slice : Bytes) : Int64
def write(slice : Bytes) : Nil
check_open
return 0i64 if slice.empty?
write_header
written = 0i64
while slice.size > 0
write_size = slice.size
write_size = @buffer.size if write_size > @buffer.size
@buffer.to_unsafe.clear(@buffer.size)

comp_size = LibLZ4.compress_update(@context, @buffer.to_unsafe, @buffer.size, slice.to_unsafe, write_size, nil)
raise LZ4Error.new("Compression failed: #{String.new(LibLZ4.get_error_name(comp_size))}") unless LibLZ4.is_error(comp_size) == 0
written += @output.write(@buffer[...comp_size]) if comp_size > 0
@output.write(@buffer[...comp_size]) if comp_size > 0
# 0 means data was buffered, to avoid buffer too small problem at end,
# let's flush the data manually
flush if comp_size == 0
slice = slice[write_size..]
end
written
end

# See `IO#flush`.
Expand Down

0 comments on commit adf3889

Please sign in to comment.