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 +4 -4
- data/.travis.yml +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +1 -4
- data/ext/mochilo/buffer.c +14 -11
- data/ext/mochilo/buffer.h +2 -2
- data/lib/mochilo/version.rb +1 -1
- data/mochilo.gemspec +0 -2
- data/script/bootstrap +1 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d82e754f7a2bb538e67c8adf3bb6bb69b99217e
|
4
|
+
data.tar.gz: c3149f3843ab0627a63aca89202defee06923cf9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d8b64f21e023a7964acd1d4da66e08be2af5298a51c53bd58b60dccea91f0e8b10e0ef4d0a0f53a4b391b125361d8c4e4d27a962ca36a766f27ac6e6461fb5f
|
7
|
+
data.tar.gz: e8a87d90c3151bdcaf22e1a1d91c302303d40ea0b38e2c3b3f874b5f3fe6ddbf5a062259bf01b85a9771ddc3738b560635eff58a60c19ac87fca1ee99436be3e
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
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
|
-
|
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
|
-
|
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
|
-
|
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
|
103
|
+
if ((buf->chunk_count * 2) < buf->chunk_count)
|
104
|
+
rb_raise(rb_eArgError, "Too many chunks required to serialize");
|
102
105
|
|
103
|
-
|
104
|
-
if (!
|
105
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
84
|
+
chunk = mochilo_buf_rechunk(b); };
|
85
85
|
|
86
86
|
#define SRC_CHECK_AVAIL(src, bytes) (src->ptr + bytes <= src->end)
|
87
87
|
|
data/lib/mochilo/version.rb
CHANGED
data/mochilo.gemspec
CHANGED
data/script/bootstrap
CHANGED
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:
|
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:
|
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: []
|