mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-13 22:50:19 +02:00
lang/c/msgpack: C++ binding: safer memory managent
git-svn-id: file:///Users/frsyuki/project/msgpack-git/svn/x@68 5a5092ae-2292-43ba-b2d5-dcab9c1a2731
This commit is contained in:
16
cpp/test.cpp
16
cpp/test.cpp
@@ -152,9 +152,7 @@ int main(void)
|
||||
unsigned num_msg = 0;
|
||||
static const size_t RESERVE_SIZE = 32;//*1024;
|
||||
|
||||
std::auto_ptr<zone> pz(new zone());
|
||||
|
||||
unpacker pac(*pz);
|
||||
unpacker pac;
|
||||
|
||||
while(stream.good() && total_bytes > 0) {
|
||||
|
||||
@@ -179,13 +177,15 @@ int main(void)
|
||||
// 5.1. take out the parsed object
|
||||
object o = pac.data();
|
||||
|
||||
// do something using pz and o
|
||||
// 5.2 release the zone
|
||||
std::auto_ptr<zone> olife( pac.release_zone() );
|
||||
|
||||
// 5.3 re-initialize the unpacker */
|
||||
pac.reset();
|
||||
|
||||
// do some with the o and olife
|
||||
std::cout << "message parsed: " << o << std::endl;
|
||||
++num_msg;
|
||||
|
||||
// 5.3 re-initialize unpacker with next zone */
|
||||
pz.reset(new zone());
|
||||
pac.reset(*pz);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user