lzfse 0.0.1 → 0.0.2.pre.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d93afc84507f8ee93fad095b695bc31972ba11ed7f725456dfcb1c413b447593
4
- data.tar.gz: 11656c01ec0f25b234f46027a008137d2e123ab40a6a6ab0b1b76f35b1a266a3
3
+ metadata.gz: 893e8dae1b749230d817fca25813d2fbbf3830e76fef047fd1d175b23caa6d17
4
+ data.tar.gz: d4ac8f4b66cd641673bcfa5ab4c93bed493a31ea8411c3d5dc616f352ed5e903
5
5
  SHA512:
6
- metadata.gz: 1789e65d35e76c2dfcb16fe43b0221b21d5f9963902b0f584d0e43a3a85b3c48a3156892b7740ceeff32dc1e30e66a818b05b2e8eabb9a24076f6d151de0baea
7
- data.tar.gz: 690dd69829f2566699b992ea417ad31e06547f606e09f90eb9ae8db001a9d75b123d9b819af61f49e736549cc1e958966f22a9adcba1bd335c7268883e432efb
6
+ metadata.gz: 90c243620b32457fa044912aae15ff04138b4143692553a8c3e49d3406a623058d36c88272e3097aa8b5251752a497741c92791ff96a168b5246ae3c83350f7c
7
+ data.tar.gz: aa43499b00d95cb92f99e2df242ef27c7417db1315f89a4ab8b4619dea83164dc5ab8b634897b54448915b37e81b0ae1228fe6b9e1a1f836e0d6c9cae570499f
data/ext/lzfse/ext.c CHANGED
@@ -43,43 +43,22 @@ static VALUE mLZFSE_lzfse_decode_intern(VALUE self, VALUE input) {
43
43
  // from there.
44
44
  size_t output_len = input_len * 2;
45
45
  uint8_t *output_buf = malloc(output_len);
46
+ size_t bytes_written = 0;
46
47
 
47
- // NOTE(ww): The public `lzfse_decode_buffer` API is a little bit braindead,
48
- // so we use the "internal" `lzfse_decode` API instead. This requires
49
- // us to set the decoder state up for ourselves.
50
- void *scratch_buffer = malloc(lzfse_decode_scratch_size() + 1);
51
- lzfse_decoder_state *state = (lzfse_decoder_state *)scratch_buffer;
52
-
53
- // NOTE(ww): It would be nice if there was an allocate-on-demand API, but
54
- // there isn't. So we do things the bad way.
55
48
  do {
56
- // We have to update each of these fields with every try, to avoid
57
- // mixing-and-matching decompression states between attempts.
58
- memset(state, 0x00, sizeof(lzfse_decoder_state));
59
- state->src = input_buf;
60
- state->src_begin = input_buf;
61
- state->src_end = input_buf + input_len;
62
- state->dst = output_buf;
63
- state->dst_begin = output_buf;
64
- state->dst_end = output_buf + output_len;
65
-
66
- int status = lzfse_decode(state);
67
- if (status == LZFSE_STATUS_OK) {
49
+ bytes_written = lzfse_decode_buffer(output_buf, output_len, input_buf, input_len, NULL);
50
+
51
+ if (bytes_written < output_len) {
52
+ // Successful decode.
68
53
  break;
69
- } else if (status == LZFSE_STATUS_DST_FULL) {
70
- // Try again. There is almost certainly a better way of doing this
71
- // that involves preserving the decoder state and reusing the partially
72
- // decoded buffer, but this suffices for now.
54
+ } else {
55
+ // Try again with a bigger buffer.
73
56
  output_len *= 2;
74
57
  output_buf = realloc(output_buf, output_len);
75
- } else {
76
- rb_raise(cDecodeError, "internal error while decoding (%d)", status);
77
58
  }
78
59
  } while (true);
79
60
 
80
- free(scratch_buffer);
81
-
82
- VALUE output_str = rb_str_new((char *)output_buf, state->dst - output_buf);
61
+ VALUE output_str = rb_str_new((char *)output_buf, bytes_written);
83
62
  free(output_buf);
84
63
 
85
64
  return output_str;
data/lib/lzfse/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LZFSE
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2.pre.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lzfse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2.pre.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Woodruff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-02 00:00:00.000000000 Z
11
+ date: 2023-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -97,9 +97,6 @@ files:
97
97
  - lib/lzfse.rb
98
98
  - lib/lzfse/exceptions.rb
99
99
  - lib/lzfse/version.rb
100
- - vendor/bundle/ruby/2.7.0/gems/rainbow-3.0.0/LICENSE
101
- - vendor/bundle/ruby/2.7.0/gems/regexp_parser-2.1.1/LICENSE
102
- - vendor/bundle/ruby/2.7.0/gems/yard-0.9.26/LICENSE
103
100
  homepage: https://github.com/woodruffw/lzfse.rb
104
101
  licenses:
105
102
  - MIT
@@ -112,14 +109,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
109
  requirements:
113
110
  - - ">="
114
111
  - !ruby/object:Gem::Version
115
- version: '2.7'
112
+ version: '3.0'
116
113
  required_rubygems_version: !ruby/object:Gem::Requirement
117
114
  requirements:
118
- - - ">="
115
+ - - ">"
119
116
  - !ruby/object:Gem::Version
120
- version: '0'
117
+ version: 1.3.1
121
118
  requirements: []
122
- rubygems_version: 3.1.4
119
+ rubygems_version: 3.3.5
123
120
  signing_key:
124
121
  specification_version: 4
125
122
  summary: Ruby bindings for Apple's LZFSE (+ LZVN)
@@ -1,20 +0,0 @@
1
- Copyright (c) Marcin Kulik
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,22 +0,0 @@
1
- Copyright (c) 2010, 2012-2015, Ammar Ali
2
-
3
- Permission is hereby granted, free of charge, to any person
4
- obtaining a copy of this software and associated documentation
5
- files (the "Software"), to deal in the Software without
6
- restriction, including without limitation the rights to use,
7
- copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- copies of the Software, and to permit persons to whom the
9
- Software is furnished to do so, subject to the following
10
- conditions:
11
-
12
- The above copyright notice and this permission notice shall be
13
- included in all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
- OTHER DEALINGS IN THE SOFTWARE.
@@ -1,22 +0,0 @@
1
- Copyright (c) 2007-2018 Loren Segal
2
-
3
- Permission is hereby granted, free of charge, to any person
4
- obtaining a copy of this software and associated documentation
5
- files (the "Software"), to deal in the Software without
6
- restriction, including without limitation the rights to use,
7
- copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- copies of the Software, and to permit persons to whom the
9
- Software is furnished to do so, subject to the following
10
- conditions:
11
-
12
- The above copyright notice and this permission notice shall be
13
- included in all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
- OTHER DEALINGS IN THE SOFTWARE.