z85 0.8 → 0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/ext/z85/z85.c +4 -19
  3. data/lib/z85/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e683619c908d319f091ecaadc76c7e59786da2d7226063e7ea876dd14fffbd8
4
- data.tar.gz: e4b648c8f706318a8c47bd150e713308da299d02e4814a604ef9bbe9cabe0a80
3
+ metadata.gz: 2b8a8f710b44f09a0f49dcd06e762772a7be52afe545c9704c9bfc3b8fb18686
4
+ data.tar.gz: 0ca0ddb2f4a4acb520be1ff60e5ccb1e2c570db10ec7c1cc2dc94635b68c05ae
5
5
  SHA512:
6
- metadata.gz: ece12a6308cb55fd09ba0f698b15090037e512487e2d70c510ec0132d6c38c062a47707f32ef3939628790774405fb3dc36664a2d914b054e1e915f6deaba378
7
- data.tar.gz: 1aa6f0004fb069b400ff31306ed5a035ddceb96a8efb1c8c16514c5bdc4cf1b331205556d2a70edc9dfe7340d73e3af161ba9824f45efd87a331042563fce9b6
6
+ metadata.gz: 288828a461c5de1c20ae44c03b275dfa5c21264517c397be2bb03bf7da5c4bfd59d4d882afe5d3c258f8279836513a1508b712d6225e981813f690fcf8fa76ea
7
+ data.tar.gz: 782da75afcaeaca47cddc7dfd85893b96ca8ddec4d9f32721e39027803f236d754a80d88c8f3114e9787df70a61f3d12bd6c3cd582a2d7f9bbdb8ceb1f8558df
@@ -60,28 +60,13 @@ static byte decoder[96] = {
60
60
  0x21, 0x22, 0x23, 0x4F, 0x00, 0x50, 0x00, 0x00
61
61
  };
62
62
 
63
- static void* z85_malloc(size_t size)
64
- {
65
- void* ptr = malloc(size);
66
-
67
- /*
68
- malloc(0) is implementation-defined and could return NULL, so if ptr is
69
- NULL, we need to check size too before raising. Note that free(NULL) is
70
- valid (it does nothing).
71
- */
72
- if (!ptr && size)
73
- rb_raise(rb_eNoMemError, "Out of memory");
74
-
75
- return ptr;
76
- }
77
-
78
63
  static VALUE z85_encode(VALUE _mod, VALUE string)
79
64
  {
80
65
  byte* data = (byte*) StringValuePtr(string);
81
66
  long size = RSTRING_LEN(string);
82
67
 
83
68
  size_t encoded_len = size * 5 / 4;
84
- char* encoded = z85_malloc(encoded_len + 1);
69
+ char* encoded = xmalloc(encoded_len + 1);
85
70
  uint char_nbr = 0;
86
71
  uint byte_nbr = 0;
87
72
  uint32_t value = 0;
@@ -100,7 +85,7 @@ static VALUE z85_encode(VALUE _mod, VALUE string)
100
85
  encoded[char_nbr] = 0;
101
86
 
102
87
  VALUE out = rb_usascii_str_new_cstr(encoded);
103
- free(encoded);
88
+ xfree(encoded);
104
89
  return out;
105
90
  }
106
91
 
@@ -112,7 +97,7 @@ static VALUE z85_decode(VALUE _mod, VALUE rstring)
112
97
  strlen--; /* It is padded, ignore the counter */
113
98
 
114
99
  size_t decoded_size = strlen * 4 / 5;
115
- byte* decoded = z85_malloc(decoded_size);
100
+ byte* decoded = xmalloc(decoded_size);
116
101
 
117
102
  uint byte_nbr = 0;
118
103
  uint char_nbr = 0;
@@ -130,7 +115,7 @@ static VALUE z85_decode(VALUE _mod, VALUE rstring)
130
115
  }
131
116
 
132
117
  VALUE out = rb_str_new((const char*) decoded, decoded_size);
133
- free(decoded);
118
+ xfree(decoded);
134
119
  return out;
135
120
  }
136
121
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Z85
4
- VERSION = "0.8"
4
+ VERSION = "0.9"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: z85
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.8'
4
+ version: '0.9'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xavier Noria