sq_detailed_metrics 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/extconf.rb +26 -0
- data/include/half.hpp +4575 -0
- data/include/msgpack.h +24 -0
- data/include/msgpack/fbuffer.h +42 -0
- data/include/msgpack/gcc_atomic.h +25 -0
- data/include/msgpack/object.h +118 -0
- data/include/msgpack/pack.h +174 -0
- data/include/msgpack/pack_define.h +18 -0
- data/include/msgpack/pack_template.h +952 -0
- data/include/msgpack/sbuffer.h +115 -0
- data/include/msgpack/sysdep.h +221 -0
- data/include/msgpack/timestamp.h +58 -0
- data/include/msgpack/unpack.h +281 -0
- data/include/msgpack/unpack_define.h +89 -0
- data/include/msgpack/unpack_template.h +471 -0
- data/include/msgpack/util.h +15 -0
- data/include/msgpack/version.h +38 -0
- data/include/msgpack/version_master.h +3 -0
- data/include/msgpack/vrefbuffer.h +144 -0
- data/include/msgpack/zbuffer.h +205 -0
- data/include/msgpack/zone.h +163 -0
- data/include/rapidjson/allocators.h +271 -0
- data/include/rapidjson/document.h +2575 -0
- data/include/rapidjson/encodedstream.h +299 -0
- data/include/rapidjson/encodings.h +716 -0
- data/include/rapidjson/error/en.h +74 -0
- data/include/rapidjson/error/error.h +155 -0
- data/include/rapidjson/filereadstream.h +99 -0
- data/include/rapidjson/filewritestream.h +104 -0
- data/include/rapidjson/fwd.h +151 -0
- data/include/rapidjson/internal/biginteger.h +290 -0
- data/include/rapidjson/internal/diyfp.h +258 -0
- data/include/rapidjson/internal/dtoa.h +245 -0
- data/include/rapidjson/internal/ieee754.h +78 -0
- data/include/rapidjson/internal/itoa.h +304 -0
- data/include/rapidjson/internal/meta.h +181 -0
- data/include/rapidjson/internal/pow10.h +55 -0
- data/include/rapidjson/internal/regex.h +701 -0
- data/include/rapidjson/internal/stack.h +230 -0
- data/include/rapidjson/internal/strfunc.h +55 -0
- data/include/rapidjson/internal/strtod.h +269 -0
- data/include/rapidjson/internal/swap.h +46 -0
- data/include/rapidjson/istreamwrapper.h +115 -0
- data/include/rapidjson/memorybuffer.h +70 -0
- data/include/rapidjson/memorystream.h +71 -0
- data/include/rapidjson/msinttypes/inttypes.h +316 -0
- data/include/rapidjson/msinttypes/stdint.h +300 -0
- data/include/rapidjson/ostreamwrapper.h +81 -0
- data/include/rapidjson/pointer.h +1358 -0
- data/include/rapidjson/prettywriter.h +255 -0
- data/include/rapidjson/rapidjson.h +615 -0
- data/include/rapidjson/reader.h +1879 -0
- data/include/rapidjson/schema.h +2006 -0
- data/include/rapidjson/stream.h +179 -0
- data/include/rapidjson/stringbuffer.h +117 -0
- data/include/rapidjson/writer.h +610 -0
- data/include/xxhash.h +328 -0
- data/json_conv.cpp +284 -0
- data/json_conv.hpp +17 -0
- data/metrics.cpp +239 -0
- data/metrics.hpp +84 -0
- data/msgpack/objectc.c +482 -0
- data/msgpack/unpack.c +703 -0
- data/msgpack/version.c +22 -0
- data/msgpack/vrefbuffer.c +250 -0
- data/msgpack/zone.c +222 -0
- data/sq_detailed_metrics.cpp +248 -0
- metadata +199 -0
data/msgpack/version.c
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#include "msgpack.h"
|
2
|
+
|
3
|
+
const char* msgpack_version(void)
|
4
|
+
{
|
5
|
+
return MSGPACK_VERSION;
|
6
|
+
}
|
7
|
+
|
8
|
+
int msgpack_version_major(void)
|
9
|
+
{
|
10
|
+
return MSGPACK_VERSION_MAJOR;
|
11
|
+
}
|
12
|
+
|
13
|
+
int msgpack_version_minor(void)
|
14
|
+
{
|
15
|
+
return MSGPACK_VERSION_MINOR;
|
16
|
+
}
|
17
|
+
|
18
|
+
int msgpack_version_revision(void)
|
19
|
+
{
|
20
|
+
return MSGPACK_VERSION_REVISION;
|
21
|
+
}
|
22
|
+
|
@@ -0,0 +1,250 @@
|
|
1
|
+
/*
|
2
|
+
* MessagePack for C zero-copy buffer implementation
|
3
|
+
*
|
4
|
+
* Copyright (C) 2008-2009 FURUHASHI Sadayuki
|
5
|
+
*
|
6
|
+
* Distributed under the Boost Software License, Version 1.0.
|
7
|
+
* (See accompanying file LICENSE_1_0.txt or copy at
|
8
|
+
* http://www.boost.org/LICENSE_1_0.txt)
|
9
|
+
*/
|
10
|
+
#include "msgpack/vrefbuffer.h"
|
11
|
+
#include <stdlib.h>
|
12
|
+
#include <string.h>
|
13
|
+
|
14
|
+
#define MSGPACK_PACKER_MAX_BUFFER_SIZE 9
|
15
|
+
|
16
|
+
struct msgpack_vrefbuffer_chunk {
|
17
|
+
struct msgpack_vrefbuffer_chunk* next;
|
18
|
+
/* data ... */
|
19
|
+
};
|
20
|
+
|
21
|
+
bool msgpack_vrefbuffer_init(msgpack_vrefbuffer* vbuf,
|
22
|
+
size_t ref_size, size_t chunk_size)
|
23
|
+
{
|
24
|
+
size_t nfirst;
|
25
|
+
struct iovec* array;
|
26
|
+
msgpack_vrefbuffer_chunk* chunk;
|
27
|
+
|
28
|
+
if (ref_size == 0) {
|
29
|
+
ref_size = MSGPACK_VREFBUFFER_REF_SIZE;
|
30
|
+
}
|
31
|
+
if(chunk_size == 0) {
|
32
|
+
chunk_size = MSGPACK_VREFBUFFER_CHUNK_SIZE;
|
33
|
+
}
|
34
|
+
vbuf->chunk_size = chunk_size;
|
35
|
+
vbuf->ref_size =
|
36
|
+
ref_size > MSGPACK_PACKER_MAX_BUFFER_SIZE + 1 ?
|
37
|
+
ref_size : MSGPACK_PACKER_MAX_BUFFER_SIZE + 1 ;
|
38
|
+
|
39
|
+
if((sizeof(msgpack_vrefbuffer_chunk) + chunk_size) < chunk_size) {
|
40
|
+
return false;
|
41
|
+
}
|
42
|
+
|
43
|
+
nfirst = (sizeof(struct iovec) < 72/2) ?
|
44
|
+
72 / sizeof(struct iovec) : 8;
|
45
|
+
|
46
|
+
array = (struct iovec*)malloc(
|
47
|
+
sizeof(struct iovec) * nfirst);
|
48
|
+
if(array == NULL) {
|
49
|
+
return false;
|
50
|
+
}
|
51
|
+
|
52
|
+
vbuf->tail = array;
|
53
|
+
vbuf->end = array + nfirst;
|
54
|
+
vbuf->array = array;
|
55
|
+
|
56
|
+
chunk = (msgpack_vrefbuffer_chunk*)malloc(
|
57
|
+
sizeof(msgpack_vrefbuffer_chunk) + chunk_size);
|
58
|
+
if(chunk == NULL) {
|
59
|
+
free(array);
|
60
|
+
return false;
|
61
|
+
}
|
62
|
+
else {
|
63
|
+
msgpack_vrefbuffer_inner_buffer* const ib = &vbuf->inner_buffer;
|
64
|
+
|
65
|
+
ib->free = chunk_size;
|
66
|
+
ib->ptr = ((char*)chunk) + sizeof(msgpack_vrefbuffer_chunk);
|
67
|
+
ib->head = chunk;
|
68
|
+
chunk->next = NULL;
|
69
|
+
|
70
|
+
return true;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
void msgpack_vrefbuffer_destroy(msgpack_vrefbuffer* vbuf)
|
75
|
+
{
|
76
|
+
msgpack_vrefbuffer_chunk* c = vbuf->inner_buffer.head;
|
77
|
+
while(true) {
|
78
|
+
msgpack_vrefbuffer_chunk* n = c->next;
|
79
|
+
free(c);
|
80
|
+
if(n != NULL) {
|
81
|
+
c = n;
|
82
|
+
} else {
|
83
|
+
break;
|
84
|
+
}
|
85
|
+
}
|
86
|
+
free(vbuf->array);
|
87
|
+
}
|
88
|
+
|
89
|
+
void msgpack_vrefbuffer_clear(msgpack_vrefbuffer* vbuf)
|
90
|
+
{
|
91
|
+
msgpack_vrefbuffer_chunk* c = vbuf->inner_buffer.head->next;
|
92
|
+
msgpack_vrefbuffer_chunk* n;
|
93
|
+
while(c != NULL) {
|
94
|
+
n = c->next;
|
95
|
+
free(c);
|
96
|
+
c = n;
|
97
|
+
}
|
98
|
+
|
99
|
+
{
|
100
|
+
msgpack_vrefbuffer_inner_buffer* const ib = &vbuf->inner_buffer;
|
101
|
+
msgpack_vrefbuffer_chunk* chunk = ib->head;
|
102
|
+
chunk->next = NULL;
|
103
|
+
ib->free = vbuf->chunk_size;
|
104
|
+
ib->ptr = ((char*)chunk) + sizeof(msgpack_vrefbuffer_chunk);
|
105
|
+
|
106
|
+
vbuf->tail = vbuf->array;
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
int msgpack_vrefbuffer_append_ref(msgpack_vrefbuffer* vbuf,
|
111
|
+
const char* buf, size_t len)
|
112
|
+
{
|
113
|
+
if(vbuf->tail == vbuf->end) {
|
114
|
+
const size_t nused = (size_t)(vbuf->tail - vbuf->array);
|
115
|
+
const size_t nnext = nused * 2;
|
116
|
+
|
117
|
+
struct iovec* nvec = (struct iovec*)realloc(
|
118
|
+
vbuf->array, sizeof(struct iovec)*nnext);
|
119
|
+
if(nvec == NULL) {
|
120
|
+
return -1;
|
121
|
+
}
|
122
|
+
|
123
|
+
vbuf->array = nvec;
|
124
|
+
vbuf->end = nvec + nnext;
|
125
|
+
vbuf->tail = nvec + nused;
|
126
|
+
}
|
127
|
+
|
128
|
+
vbuf->tail->iov_base = (char*)buf;
|
129
|
+
vbuf->tail->iov_len = len;
|
130
|
+
++vbuf->tail;
|
131
|
+
|
132
|
+
return 0;
|
133
|
+
}
|
134
|
+
|
135
|
+
int msgpack_vrefbuffer_append_copy(msgpack_vrefbuffer* vbuf,
|
136
|
+
const char* buf, size_t len)
|
137
|
+
{
|
138
|
+
msgpack_vrefbuffer_inner_buffer* const ib = &vbuf->inner_buffer;
|
139
|
+
char* m;
|
140
|
+
|
141
|
+
if(ib->free < len) {
|
142
|
+
msgpack_vrefbuffer_chunk* chunk;
|
143
|
+
size_t sz = vbuf->chunk_size;
|
144
|
+
if(sz < len) {
|
145
|
+
sz = len;
|
146
|
+
}
|
147
|
+
|
148
|
+
if((sizeof(msgpack_vrefbuffer_chunk) + sz) < sz){
|
149
|
+
return -1;
|
150
|
+
}
|
151
|
+
chunk = (msgpack_vrefbuffer_chunk*)malloc(
|
152
|
+
sizeof(msgpack_vrefbuffer_chunk) + sz);
|
153
|
+
if(chunk == NULL) {
|
154
|
+
return -1;
|
155
|
+
}
|
156
|
+
|
157
|
+
chunk->next = ib->head;
|
158
|
+
ib->head = chunk;
|
159
|
+
ib->free = sz;
|
160
|
+
ib->ptr = ((char*)chunk) + sizeof(msgpack_vrefbuffer_chunk);
|
161
|
+
}
|
162
|
+
|
163
|
+
m = ib->ptr;
|
164
|
+
memcpy(m, buf, len);
|
165
|
+
ib->free -= len;
|
166
|
+
ib->ptr += len;
|
167
|
+
|
168
|
+
if(vbuf->tail != vbuf->array && m ==
|
169
|
+
(const char*)((vbuf->tail-1)->iov_base) + (vbuf->tail-1)->iov_len) {
|
170
|
+
(vbuf->tail-1)->iov_len += len;
|
171
|
+
return 0;
|
172
|
+
} else {
|
173
|
+
return msgpack_vrefbuffer_append_ref(vbuf, m, len);
|
174
|
+
}
|
175
|
+
}
|
176
|
+
|
177
|
+
int msgpack_vrefbuffer_migrate(msgpack_vrefbuffer* vbuf, msgpack_vrefbuffer* to)
|
178
|
+
{
|
179
|
+
size_t sz = vbuf->chunk_size;
|
180
|
+
msgpack_vrefbuffer_chunk* empty;
|
181
|
+
|
182
|
+
if((sizeof(msgpack_vrefbuffer_chunk) + sz) < sz){
|
183
|
+
return -1;
|
184
|
+
}
|
185
|
+
|
186
|
+
empty = (msgpack_vrefbuffer_chunk*)malloc(
|
187
|
+
sizeof(msgpack_vrefbuffer_chunk) + sz);
|
188
|
+
if(empty == NULL) {
|
189
|
+
return -1;
|
190
|
+
}
|
191
|
+
|
192
|
+
empty->next = NULL;
|
193
|
+
|
194
|
+
{
|
195
|
+
const size_t nused = (size_t)(vbuf->tail - vbuf->array);
|
196
|
+
if(to->tail + nused < vbuf->end) {
|
197
|
+
struct iovec* nvec;
|
198
|
+
const size_t tosize = (size_t)(to->tail - to->array);
|
199
|
+
const size_t reqsize = nused + tosize;
|
200
|
+
size_t nnext = (size_t)(to->end - to->array) * 2;
|
201
|
+
while(nnext < reqsize) {
|
202
|
+
size_t tmp_nnext = nnext * 2;
|
203
|
+
if (tmp_nnext <= nnext) {
|
204
|
+
nnext = reqsize;
|
205
|
+
break;
|
206
|
+
}
|
207
|
+
nnext = tmp_nnext;
|
208
|
+
}
|
209
|
+
|
210
|
+
nvec = (struct iovec*)realloc(
|
211
|
+
to->array, sizeof(struct iovec)*nnext);
|
212
|
+
if(nvec == NULL) {
|
213
|
+
free(empty);
|
214
|
+
return -1;
|
215
|
+
}
|
216
|
+
|
217
|
+
to->array = nvec;
|
218
|
+
to->end = nvec + nnext;
|
219
|
+
to->tail = nvec + tosize;
|
220
|
+
}
|
221
|
+
|
222
|
+
memcpy(to->tail, vbuf->array, sizeof(struct iovec)*nused);
|
223
|
+
|
224
|
+
to->tail += nused;
|
225
|
+
vbuf->tail = vbuf->array;
|
226
|
+
|
227
|
+
{
|
228
|
+
msgpack_vrefbuffer_inner_buffer* const ib = &vbuf->inner_buffer;
|
229
|
+
msgpack_vrefbuffer_inner_buffer* const toib = &to->inner_buffer;
|
230
|
+
|
231
|
+
msgpack_vrefbuffer_chunk* last = ib->head;
|
232
|
+
while(last->next != NULL) {
|
233
|
+
last = last->next;
|
234
|
+
}
|
235
|
+
last->next = toib->head;
|
236
|
+
toib->head = ib->head;
|
237
|
+
|
238
|
+
if(toib->free < ib->free) {
|
239
|
+
toib->free = ib->free;
|
240
|
+
toib->ptr = ib->ptr;
|
241
|
+
}
|
242
|
+
|
243
|
+
ib->head = empty;
|
244
|
+
ib->free = sz;
|
245
|
+
ib->ptr = ((char*)empty) + sizeof(msgpack_vrefbuffer_chunk);
|
246
|
+
}
|
247
|
+
}
|
248
|
+
|
249
|
+
return 0;
|
250
|
+
}
|
data/msgpack/zone.c
ADDED
@@ -0,0 +1,222 @@
|
|
1
|
+
/*
|
2
|
+
* MessagePack for C memory pool implementation
|
3
|
+
*
|
4
|
+
* Copyright (C) 2008-2009 FURUHASHI Sadayuki
|
5
|
+
*
|
6
|
+
* Distributed under the Boost Software License, Version 1.0.
|
7
|
+
* (See accompanying file LICENSE_1_0.txt or copy at
|
8
|
+
* http://www.boost.org/LICENSE_1_0.txt)
|
9
|
+
*/
|
10
|
+
#include "msgpack/zone.h"
|
11
|
+
#include <stdlib.h>
|
12
|
+
#include <string.h>
|
13
|
+
|
14
|
+
struct msgpack_zone_chunk {
|
15
|
+
struct msgpack_zone_chunk* next;
|
16
|
+
/* data ... */
|
17
|
+
};
|
18
|
+
|
19
|
+
static inline bool init_chunk_list(msgpack_zone_chunk_list* cl, size_t chunk_size)
|
20
|
+
{
|
21
|
+
msgpack_zone_chunk* chunk = (msgpack_zone_chunk*)malloc(
|
22
|
+
sizeof(msgpack_zone_chunk) + chunk_size);
|
23
|
+
if(chunk == NULL) {
|
24
|
+
return false;
|
25
|
+
}
|
26
|
+
|
27
|
+
cl->head = chunk;
|
28
|
+
cl->free = chunk_size;
|
29
|
+
cl->ptr = ((char*)chunk) + sizeof(msgpack_zone_chunk);
|
30
|
+
chunk->next = NULL;
|
31
|
+
|
32
|
+
return true;
|
33
|
+
}
|
34
|
+
|
35
|
+
static inline void destroy_chunk_list(msgpack_zone_chunk_list* cl)
|
36
|
+
{
|
37
|
+
msgpack_zone_chunk* c = cl->head;
|
38
|
+
while(true) {
|
39
|
+
msgpack_zone_chunk* n = c->next;
|
40
|
+
free(c);
|
41
|
+
if(n != NULL) {
|
42
|
+
c = n;
|
43
|
+
} else {
|
44
|
+
break;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
static inline void clear_chunk_list(msgpack_zone_chunk_list* cl, size_t chunk_size)
|
50
|
+
{
|
51
|
+
msgpack_zone_chunk* c = cl->head;
|
52
|
+
while(true) {
|
53
|
+
msgpack_zone_chunk* n = c->next;
|
54
|
+
if(n != NULL) {
|
55
|
+
free(c);
|
56
|
+
c = n;
|
57
|
+
} else {
|
58
|
+
cl->head = c;
|
59
|
+
break;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
cl->head->next = NULL;
|
63
|
+
cl->free = chunk_size;
|
64
|
+
cl->ptr = ((char*)cl->head) + sizeof(msgpack_zone_chunk);
|
65
|
+
}
|
66
|
+
|
67
|
+
void* msgpack_zone_malloc_expand(msgpack_zone* zone, size_t size)
|
68
|
+
{
|
69
|
+
msgpack_zone_chunk_list* const cl = &zone->chunk_list;
|
70
|
+
msgpack_zone_chunk* chunk;
|
71
|
+
|
72
|
+
size_t sz = zone->chunk_size;
|
73
|
+
|
74
|
+
while(sz < size) {
|
75
|
+
size_t tmp_sz = sz * 2;
|
76
|
+
if (tmp_sz <= sz) {
|
77
|
+
sz = size;
|
78
|
+
break;
|
79
|
+
}
|
80
|
+
sz = tmp_sz;
|
81
|
+
}
|
82
|
+
|
83
|
+
chunk = (msgpack_zone_chunk*)malloc(
|
84
|
+
sizeof(msgpack_zone_chunk) + sz);
|
85
|
+
if (chunk == NULL) {
|
86
|
+
return NULL;
|
87
|
+
}
|
88
|
+
else {
|
89
|
+
char* ptr = ((char*)chunk) + sizeof(msgpack_zone_chunk);
|
90
|
+
chunk->next = cl->head;
|
91
|
+
cl->head = chunk;
|
92
|
+
cl->free = sz - size;
|
93
|
+
cl->ptr = ptr + size;
|
94
|
+
|
95
|
+
return ptr;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
|
100
|
+
static inline void init_finalizer_array(msgpack_zone_finalizer_array* fa)
|
101
|
+
{
|
102
|
+
fa->tail = NULL;
|
103
|
+
fa->end = NULL;
|
104
|
+
fa->array = NULL;
|
105
|
+
}
|
106
|
+
|
107
|
+
static inline void call_finalizer_array(msgpack_zone_finalizer_array* fa)
|
108
|
+
{
|
109
|
+
msgpack_zone_finalizer* fin = fa->tail;
|
110
|
+
for(; fin != fa->array; --fin) {
|
111
|
+
(*(fin-1)->func)((fin-1)->data);
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
static inline void destroy_finalizer_array(msgpack_zone_finalizer_array* fa)
|
116
|
+
{
|
117
|
+
call_finalizer_array(fa);
|
118
|
+
free(fa->array);
|
119
|
+
}
|
120
|
+
|
121
|
+
static inline void clear_finalizer_array(msgpack_zone_finalizer_array* fa)
|
122
|
+
{
|
123
|
+
call_finalizer_array(fa);
|
124
|
+
fa->tail = fa->array;
|
125
|
+
}
|
126
|
+
|
127
|
+
bool msgpack_zone_push_finalizer_expand(msgpack_zone* zone,
|
128
|
+
void (*func)(void* data), void* data)
|
129
|
+
{
|
130
|
+
msgpack_zone_finalizer_array* const fa = &zone->finalizer_array;
|
131
|
+
msgpack_zone_finalizer* tmp;
|
132
|
+
|
133
|
+
const size_t nused = (size_t)(fa->end - fa->array);
|
134
|
+
|
135
|
+
size_t nnext;
|
136
|
+
if(nused == 0) {
|
137
|
+
nnext = (sizeof(msgpack_zone_finalizer) < 72/2) ?
|
138
|
+
72 / sizeof(msgpack_zone_finalizer) : 8;
|
139
|
+
|
140
|
+
} else {
|
141
|
+
nnext = nused * 2;
|
142
|
+
}
|
143
|
+
|
144
|
+
tmp = (msgpack_zone_finalizer*)realloc(fa->array,
|
145
|
+
sizeof(msgpack_zone_finalizer) * nnext);
|
146
|
+
if(tmp == NULL) {
|
147
|
+
return false;
|
148
|
+
}
|
149
|
+
|
150
|
+
fa->array = tmp;
|
151
|
+
fa->end = tmp + nnext;
|
152
|
+
fa->tail = tmp + nused;
|
153
|
+
|
154
|
+
fa->tail->func = func;
|
155
|
+
fa->tail->data = data;
|
156
|
+
|
157
|
+
++fa->tail;
|
158
|
+
|
159
|
+
return true;
|
160
|
+
}
|
161
|
+
|
162
|
+
|
163
|
+
bool msgpack_zone_is_empty(msgpack_zone* zone)
|
164
|
+
{
|
165
|
+
msgpack_zone_chunk_list* const cl = &zone->chunk_list;
|
166
|
+
msgpack_zone_finalizer_array* const fa = &zone->finalizer_array;
|
167
|
+
return cl->free == zone->chunk_size && cl->head->next == NULL &&
|
168
|
+
fa->tail == fa->array;
|
169
|
+
}
|
170
|
+
|
171
|
+
|
172
|
+
void msgpack_zone_destroy(msgpack_zone* zone)
|
173
|
+
{
|
174
|
+
destroy_finalizer_array(&zone->finalizer_array);
|
175
|
+
destroy_chunk_list(&zone->chunk_list);
|
176
|
+
}
|
177
|
+
|
178
|
+
void msgpack_zone_clear(msgpack_zone* zone)
|
179
|
+
{
|
180
|
+
clear_finalizer_array(&zone->finalizer_array);
|
181
|
+
clear_chunk_list(&zone->chunk_list, zone->chunk_size);
|
182
|
+
}
|
183
|
+
|
184
|
+
bool msgpack_zone_init(msgpack_zone* zone, size_t chunk_size)
|
185
|
+
{
|
186
|
+
zone->chunk_size = chunk_size;
|
187
|
+
|
188
|
+
if(!init_chunk_list(&zone->chunk_list, chunk_size)) {
|
189
|
+
return false;
|
190
|
+
}
|
191
|
+
|
192
|
+
init_finalizer_array(&zone->finalizer_array);
|
193
|
+
|
194
|
+
return true;
|
195
|
+
}
|
196
|
+
|
197
|
+
msgpack_zone* msgpack_zone_new(size_t chunk_size)
|
198
|
+
{
|
199
|
+
msgpack_zone* zone = (msgpack_zone*)malloc(
|
200
|
+
sizeof(msgpack_zone));
|
201
|
+
if(zone == NULL) {
|
202
|
+
return NULL;
|
203
|
+
}
|
204
|
+
|
205
|
+
zone->chunk_size = chunk_size;
|
206
|
+
|
207
|
+
if(!init_chunk_list(&zone->chunk_list, chunk_size)) {
|
208
|
+
free(zone);
|
209
|
+
return NULL;
|
210
|
+
}
|
211
|
+
|
212
|
+
init_finalizer_array(&zone->finalizer_array);
|
213
|
+
|
214
|
+
return zone;
|
215
|
+
}
|
216
|
+
|
217
|
+
void msgpack_zone_free(msgpack_zone* zone)
|
218
|
+
{
|
219
|
+
if(zone == NULL) { return; }
|
220
|
+
msgpack_zone_destroy(zone);
|
221
|
+
free(zone);
|
222
|
+
}
|