When the original PR was applied, the resource leak had been fixed, but a dual free problem had been happened.
When msgpack_unpacker_next returns MSGPACK_UNPACK_CONTINUE, msgpack_unpacked::zone is not replaced. Then mespack_zone_free is called twice with the same object. msgpack_unpacked_destroy frees msgpack::zone when it is not NULL and set it to NULL.
Also, fixed memory leak (msgpack_sbuffer) on the test code.
Added a referenced parameter to msgpack::unpack() and msgpack::unpacker::next().
msgpack::unpacked is a kind of handler that holds msgpack::object and msgpack::zone, so the size of msgpack::unpacked should be small. There is no reason to have referenced in msgpack::unpacked. msgpack user can get the same information using msgpack::unpack() and msgpack::unpacker::next().
Even if ref_size is given on vrefbuffer's constructor, the minimum size of vrefbuffer::ref_buffer is 10.
Because int64, uint64, and double's msgpack expression size equals 9, and those buffer is allocated on the stack internally.
Fixed referenced flag writing timing on next(). It should place before flush.
Added msgpack_tuple test for CMakeLists.txt
Untabified CMakeLists.txt
Added reference function test.
Removed obsolete unpack functions.
Updated examples that no longer use obsolete functions.
Added reference checking function to unpacked. ( unpacked::referenced() )
Added std:: namespace.
Added reference or copy choice function and default behavior:
When you use unpacker, default behavior is:
STR, BIN, EXT types are always held by reference.
When you don't use unpacker, default behavior is:
STR, BIN, EXT types are always held by copy.
The memory is allocated from zone.
You can customize the behavior passing your custom judging function to unpack() or unpacker's constructor.
std::vector<char> is mapped to BIN.
So, currently BIN, STR, and ARRAY mappings are as follows:
std::vector<char> is mapped to BIN
std::string is mapped to STR
std::vector<T> is mapped to ARRAY // T is not char
It assures that we can use the same interfaces as the original version(0.5.6).
To support both C++03 and C++11, I introduced msgpack::unique_ptr and msgpack::move() in test codes.
When the compiler configured to support C++11 (e.g. CXXFLAG contains -std=c++11 is given),
those files are used.
Decoupled unpacker and msgpack_unpacker.
This modification introduced C++11 dependency such as nullptr and unique_ptr.
I will support C++11 and C++03, finally.
Decoupled msgpack.hpp and msgpack.h.
Decoupled sbuffer from msgpack_sbuffer.
Decoupled vrefbuffer from msgpack_vrefbuffer.
Decoupled zbuffer from msgpack_zbuffer.
Added some z_stream initialization.
Removed unpack macros.
Removed CTX_CAST and CTX_REFERENCED.
Embed ctx_ as a member variable (not a pointer).
Modified zone free using C++ way.