Skip to content

Commit 188da01

Browse files
committed
Fix new version of msgpack.
1 parent 812c8bc commit 188da01

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

msgpack/unpack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* limitations under the License.
1717
*/
1818

19-
#define MSGPACK_MAX_STACK_SIZE (1024)
19+
#define MSGPACK_EMBED_STACK_SIZE (1024)
2020
#include "unpack_define.h"
2121

2222
typedef struct unpack_user {

msgpack/unpack_template.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848

4949
msgpack_unpack_struct_decl(_stack) {
5050
msgpack_unpack_object obj;
51+
size_t size;
5152
size_t count;
5253
unsigned int ct;
5354
msgpack_unpack_object map_key;
@@ -140,9 +141,12 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
140141
#define start_container(func, count_, ct_) \
141142
if(top >= MSGPACK_EMBED_STACK_SIZE) { goto _failed; } /* FIXME */ \
142143
if(msgpack_unpack_callback(func)(user, count_, &stack[top].obj) < 0) { goto _failed; } \
143-
if((count_) == 0) { obj = stack[top].obj; goto _push; } \
144+
if((count_) == 0) { obj = stack[top].obj; \
145+
msgpack_unpack_callback(func##_end)(user, &obj); \
146+
goto _push; } \
144147
stack[top].ct = ct_; \
145-
stack[top].count = count_; \
148+
stack[top].size = count_; \
149+
stack[top].count = 0; \
146150
++top; \
147151
/*printf("container %d count %d stack %d\n",stack[top].obj,count_,top);*/ \
148152
/*printf("stack push %d\n", top);*/ \
@@ -336,9 +340,10 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
336340
c = &stack[top-1];
337341
switch(c->ct) {
338342
case CT_ARRAY_ITEM:
339-
if(msgpack_unpack_callback(_array_item)(user, &c->obj, obj) < 0) { goto _failed; }
340-
if(--c->count == 0) {
343+
if(msgpack_unpack_callback(_array_item)(user, c->count, &c->obj, obj) < 0) { goto _failed; }
344+
if(++c->count == c->size) {
341345
obj = c->obj;
346+
msgpack_unpack_callback(_array_end)(user, &obj);
342347
--top;
343348
/*printf("stack pop %d\n", top);*/
344349
goto _push;
@@ -350,8 +355,9 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
350355
goto _header_again;
351356
case CT_MAP_VALUE:
352357
if(msgpack_unpack_callback(_map_item)(user, &c->obj, c->map_key, obj) < 0) { goto _failed; }
353-
if(--c->count == 0) {
358+
if(++c->count == c->size) {
354359
obj = c->obj;
360+
msgpack_unpack_callback(_map_end)(user, &obj);
355361
--top;
356362
/*printf("stack pop %d\n", top);*/
357363
goto _push;
@@ -411,3 +417,4 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
411417

412418
#undef NEXT_CS
413419

420+
/* vim: set ts=4 sw=4 noexpandtab */

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def __init__(self, *args, **kwargs):
5252
msgpack_mod = Extension('msgpack._msgpack',
5353
sources=sources,
5454
libraries=libraries,
55+
include_dirs=['.'],
5556
)
5657
del sources, libraries
5758

0 commit comments

Comments
 (0)