mochilo 1.2 → 1.2.1

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
  SHA1:
3
- metadata.gz: 64991c41216b4fb7659230eb433f7cb6c3f4ffff
4
- data.tar.gz: 21e5f81fdf2be02ad17303ca98636020fa2f8f78
3
+ metadata.gz: 3d82e754f7a2bb538e67c8adf3bb6bb69b99217e
4
+ data.tar.gz: c3149f3843ab0627a63aca89202defee06923cf9
5
5
  SHA512:
6
- metadata.gz: 8258d48406e1674370d61cf42562db462908a6239f8471f2033a157bc4547fe4e7793d74a516046f6326d4473e73162be9b467b35f4e6fe55f43aa09c763fec7
7
- data.tar.gz: 4e44d9ab0960cadaa4b70c15c1da0b2b10447dfe3790f80189d6ee70f697966b52bdbb9ae9546b446f7bfa860274efb8cd212f80ca26c858ddc1ad8850fc1f66
6
+ metadata.gz: 3d8b64f21e023a7964acd1d4da66e08be2af5298a51c53bd58b60dccea91f0e8b10e0ef4d0a0f53a4b391b125361d8c4e4d27a962ca36a766f27ac6e6461fb5f
7
+ data.tar.gz: e8a87d90c3151bdcaf22e1a1d91c302303d40ea0b38e2c3b3f874b5f3fe6ddbf5a062259bf01b85a9771ddc3738b560635eff58a60c19ac87fca1ee99436be3e
data/.travis.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  language: ruby
2
2
  script:
3
3
  - bundle exec rake test
4
+ install: ./script/bootstrap
4
5
  rvm:
5
6
  - 2.3.0
6
7
  - 2.2
data/Gemfile CHANGED
@@ -3,3 +3,7 @@ source "https://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  gem "pry"
6
+
7
+ group :benchmark do
8
+ gem "msgpack"
9
+ end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mochilo (1.2)
4
+ mochilo (1.2.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -28,6 +28,3 @@ DEPENDENCIES
28
28
  msgpack
29
29
  pry
30
30
  rake-compiler (>= 0.8.1)
31
-
32
- BUNDLED WITH
33
- 1.11.2
data/ext/mochilo/buffer.c CHANGED
@@ -19,7 +19,7 @@ static mochilo_buf_chunk *init_cur_chunk(mochilo_buf *buf, size_t chunk_size)
19
19
 
20
20
  buf->last_alloc = chunk->ptr = malloc(chunk_size);
21
21
  if (!chunk->ptr)
22
- return NULL;
22
+ rb_raise(rb_eNoMemError, "Failed to allocate new chunk");
23
23
 
24
24
  chunk->end = chunk->ptr + chunk_size;
25
25
  return chunk;
@@ -38,7 +38,7 @@ static void skip_last_chunk(mochilo_buf *buf)
38
38
 
39
39
  static void free_buf(mochilo_buf *buf)
40
40
  {
41
- uint16_t i;
41
+ uint32_t i;
42
42
 
43
43
  for (i = 0; i < buf->cur_chunk; ++i)
44
44
  free(buf->chunks[i].ptr);
@@ -61,7 +61,7 @@ VALUE mochilo_buf_flush(mochilo_buf *buf)
61
61
  {
62
62
  VALUE rb_str;
63
63
  char *ptr;
64
- uint16_t i;
64
+ uint32_t i;
65
65
 
66
66
  skip_last_chunk(buf);
67
67
 
@@ -95,15 +95,20 @@ VALUE mochilo_buf_flush(mochilo_buf *buf)
95
95
 
96
96
  mochilo_buf_chunk *mochilo_buf_rechunk2(mochilo_buf *buf, size_t chunk_size)
97
97
  {
98
+ mochilo_buf_chunk *chunks;
99
+
98
100
  skip_last_chunk(buf);
99
101
 
100
102
  if (buf->cur_chunk == buf->chunk_count) {
101
- buf->chunk_count *= 2;
103
+ if ((buf->chunk_count * 2) < buf->chunk_count)
104
+ rb_raise(rb_eArgError, "Too many chunks required to serialize");
102
105
 
103
- buf->chunks = realloc(buf->chunks, buf->chunk_count * sizeof(mochilo_buf_chunk));
104
- if (!buf->chunks)
105
- return NULL;
106
+ chunks = realloc(buf->chunks, buf->chunk_count * 2 * sizeof(mochilo_buf_chunk));
107
+ if (!chunks)
108
+ rb_raise(rb_eNoMemError, "Failed to realloc chunks");
106
109
 
110
+ buf->chunks = chunks;
111
+ buf->chunk_count *= 2;
107
112
  }
108
113
 
109
114
  return init_cur_chunk(buf, chunk_size);
@@ -118,10 +123,8 @@ void mochilo_buf_put(mochilo_buf *buf, const char *data, size_t len)
118
123
  {
119
124
  mochilo_buf_chunk *chunk = &buf->chunks[buf->cur_chunk];
120
125
 
121
- if (unlikely(chunk->ptr + len > chunk->end)) {
122
- if (!(chunk = mochilo_buf_rechunk2(buf, len)))
123
- return;
124
- }
126
+ if (unlikely(chunk->ptr + len > chunk->end))
127
+ chunk = mochilo_buf_rechunk2(buf, len);
125
128
 
126
129
  memmove(chunk->ptr, data, len);
127
130
  chunk->ptr += len;
data/ext/mochilo/buffer.h CHANGED
@@ -59,7 +59,7 @@ typedef struct {
59
59
  mochilo_buf_chunk *chunks;
60
60
  char *last_alloc;
61
61
  size_t total_size;
62
- uint16_t chunk_count, cur_chunk;
62
+ uint32_t chunk_count, cur_chunk;
63
63
  } mochilo_buf;
64
64
 
65
65
  typedef struct {
@@ -81,7 +81,7 @@ const char *mochilo_src_peek(mochilo_src *buf, size_t need);
81
81
  #define BUF_ENSURE_AVAIL(b, d) \
82
82
  mochilo_buf_chunk *chunk = &b->chunks[b->cur_chunk]; \
83
83
  if (unlikely(chunk->ptr + (d) > chunk->end)) { \
84
- if ((chunk = mochilo_buf_rechunk(b)) == NULL) return; };
84
+ chunk = mochilo_buf_rechunk(b); };
85
85
 
86
86
  #define SRC_CHECK_AVAIL(src, bytes) (src->ptr + bytes <= src->end)
87
87
 
@@ -1,3 +1,3 @@
1
1
  module Mochilo
2
- VERSION = "1.2"
2
+ VERSION = "1.2.1"
3
3
  end
data/mochilo.gemspec CHANGED
@@ -19,6 +19,4 @@ Gem::Specification.new do |s|
19
19
  # tests
20
20
  s.add_development_dependency 'rake-compiler', ">= 0.8.1"
21
21
  s.add_development_dependency 'minitest', ">= 4.1.0"
22
- # benchmarks
23
- s.add_development_dependency 'msgpack'
24
22
  end
data/script/bootstrap CHANGED
@@ -12,5 +12,5 @@ cd "$(dirname "$0")/.."
12
12
  if bundle check 1>/dev/null 2>&1; then
13
13
  echo "Gem environment up-to-date"
14
14
  else
15
- exec bundle install --binstubs --path vendor/gems "$@"
15
+ exec bundle install --binstubs --path vendor/gems --without benchmark "$@"
16
16
  fi
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mochilo
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.2'
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vicent Martí
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-03-02 00:00:00.000000000 Z
12
+ date: 2017-01-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake-compiler
@@ -39,20 +39,6 @@ dependencies:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: 4.1.0
42
- - !ruby/object:Gem::Dependency
43
- name: msgpack
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: '0'
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: '0'
56
42
  description:
57
43
  email: vicent@github.com seniorlopez@gmail.com
58
44
  executables: []