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:
frsyuki
2009-02-15 09:09:58 +00:00
parent 9923cf4daf
commit b790df530a
4 changed files with 102 additions and 24 deletions

View File

@@ -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);
}
}