summaryrefslogtreecommitdiff
path: root/c/unpack.c
diff options
context:
space:
mode:
authorfrsyuki <frsyuki@vcore.(none)>2009-02-26 01:15:14 +0900
committerfrsyuki <frsyuki@vcore.(none)>2009-02-26 01:15:14 +0900
commit5697b9a15d89a397a53174b9eca2d96bc7ebaef0 (patch)
tree9168b29e6d8c495001bf18573a5f712ff158c9b4 /c/unpack.c
parent8893523776e5258e2817711da75f00a6074a13ae (diff)
downloadmsgpack-python-5697b9a15d89a397a53174b9eca2d96bc7ebaef0.tar.gz
remove msgpack_unpacker_buffered_size, add msgpack_unpacker_parsed_size
Diffstat (limited to 'c/unpack.c')
-rw-r--r--c/unpack.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/c/unpack.c b/c/unpack.c
index e06d97c..865e0d4 100644
--- a/c/unpack.c
+++ b/c/unpack.c
@@ -197,6 +197,7 @@ bool msgpack_unpacker_init(msgpack_unpacker* mpac, size_t initial_buffer_size)
mpac->used = COUNTER_SIZE;
mpac->free = initial_buffer_size - mpac->used;
mpac->off = COUNTER_SIZE;
+ mpac->parsed = 0;
mpac->initial_buffer_size = initial_buffer_size;
mpac->z = z;
mpac->referenced = false;
@@ -305,8 +306,13 @@ bool msgpack_unpacker_expand_buffer(msgpack_unpacker* mpac, size_t size)
int msgpack_unpacker_execute(msgpack_unpacker* mpac)
{
- return template_execute(CTX_CAST(mpac->ctx),
+ size_t off = mpac->off;
+ int ret = template_execute(CTX_CAST(mpac->ctx),
mpac->buf, mpac->used, &mpac->off);
+ if(mpac->off > off) {
+ mpac->parsed += mpac->off - off;
+ }
+ return ret;
}
msgpack_object msgpack_unpacker_data(msgpack_unpacker* mpac)
@@ -347,10 +353,8 @@ bool msgpack_unpacker_flush_zone(msgpack_unpacker* mpac)
void msgpack_unpacker_reset(msgpack_unpacker* mpac)
{
- msgpack_zone* z = mpac->z;
template_init(CTX_CAST(mpac->ctx));
- CTX_CAST(mpac->ctx)->user.z = z;
- CTX_CAST(mpac->ctx)->user.referenced = &mpac->referenced;
+ mpac->parsed = 0;
}