diff options
| author | frsyuki <frsyuki@vcore.(none)> | 2009-02-25 23:31:53 +0900 |
|---|---|---|
| committer | frsyuki <frsyuki@vcore.(none)> | 2009-02-25 23:31:53 +0900 |
| commit | 8893523776e5258e2817711da75f00a6074a13ae (patch) | |
| tree | d23e01bca4f615e1028e3e9681e884b9521ebaf6 | |
| parent | a89dfc70b997201cea3587de922924dec2bb28e7 (diff) | |
| download | msgpack-python-8893523776e5258e2817711da75f00a6074a13ae.tar.gz | |
c: msgpack_unpacker_buffered_size; c++: unpacker::buffered_size
| -rw-r--r-- | c/unpack.h | 6 | ||||
| -rw-r--r-- | cpp/unpack.hpp | 9 |
2 files changed, 15 insertions, 0 deletions
@@ -46,6 +46,7 @@ void msgpack_unpacker_destroy(msgpack_unpacker* mpac); msgpack_unpacker* msgpack_unpacker_new(size_t initial_buffer_size); void msgpack_unpacker_free(msgpack_unpacker* mpac); +static inline size_t msgpack_unpacker_buffered_size(const msgpack_unpacker* mpac); static inline bool msgpack_unpacker_reserve_buffer(msgpack_unpacker* mpac, size_t size); static inline char* msgpack_unpacker_buffer(msgpack_unpacker* mpac); static inline size_t msgpack_unpacker_buffer_capacity(const msgpack_unpacker* mpac); @@ -77,6 +78,11 @@ bool msgpack_unpacker_flush_zone(msgpack_unpacker* mpac); bool msgpack_unpacker_expand_buffer(msgpack_unpacker* mpac, size_t size); +size_t msgpack_unpacker_buffered_size(const msgpack_unpacker* mpac) +{ + return mpac->used; +} + bool msgpack_unpacker_reserve_buffer(msgpack_unpacker* mpac, size_t size) { if(mpac->free >= size) { return true; } diff --git a/cpp/unpack.hpp b/cpp/unpack.hpp index e6d35da..6e9b641 100644 --- a/cpp/unpack.hpp +++ b/cpp/unpack.hpp @@ -43,6 +43,9 @@ public: ~unpacker(); public: + /*! 0. check if the buffered size is not exceed the assumption. */ + size_t buffered_size() const; + /*! 1. reserve buffer. at least `size' bytes of capacity will be ready */ void reserve_buffer(size_t size); @@ -154,6 +157,12 @@ inline unpacker::~unpacker() msgpack_unpacker_destroy(this); } + +inline size_t unpacker::buffered_size() const +{ + return msgpack_unpacker_buffered_size(this); +} + inline void unpacker::reserve_buffer(size_t size) { if(!msgpack_unpacker_reserve_buffer(this, size)) { |
