summaryrefslogtreecommitdiff
path: root/cpp/test.cpp
diff options
context:
space:
mode:
authorfrsyuki <frsyuki@5a5092ae-2292-43ba-b2d5-dcab9c1a2731>2009-02-15 09:09:58 +0000
committerfrsyuki <frsyuki@5a5092ae-2292-43ba-b2d5-dcab9c1a2731>2009-02-15 09:09:58 +0000
commitb790df530aa28099aa130dafad0a591004b88650 (patch)
tree4d09f4c43a5994bcf83e152471e29ac9c952ba3e /cpp/test.cpp
parent9923cf4daf631432e389dd0694042b6b405c1288 (diff)
downloadmsgpack-python-b790df530aa28099aa130dafad0a591004b88650.tar.gz
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
Diffstat (limited to 'cpp/test.cpp')
-rw-r--r--cpp/test.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/cpp/test.cpp b/cpp/test.cpp
index dff9101..c632ec5 100644
--- a/cpp/test.cpp
+++ b/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);
}
}