From 3c2a3c51dc78f90b959ab78c2b5cd68e2e9bfafa Mon Sep 17 00:00:00 2001 From: Olivier Parcollet Date: Tue, 10 Sep 2013 18:44:33 +0200 Subject: [PATCH] arrays : fix in bug in ref counting in deserialize --- triqs/arrays/storages/shared_block.hpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/triqs/arrays/storages/shared_block.hpp b/triqs/arrays/storages/shared_block.hpp index 48cb2f32..a495979e 100644 --- a/triqs/arrays/storages/shared_block.hpp +++ b/triqs/arrays/storages/shared_block.hpp @@ -100,9 +100,15 @@ namespace triqs { namespace arrays { namespace storages { private: friend class shared_block; friend class boost::serialization::access; - template void serialize(Archive & ar, const unsigned int version) { - ar & boost::serialization::make_nvp("ptr",sptr); data_ = (sptr ? sptr->p : nullptr); s = (sptr ? sptr->size() : 0); - } + template + void save(Archive & ar, const unsigned int version) const { ar << boost::serialization::make_nvp("ptr",sptr); } + template + void load(Archive & ar, const unsigned int version) { + if (sptr) dec_ref(sptr); + ar >> boost::serialization::make_nvp("ptr",sptr); data_ = (sptr ? sptr->p : nullptr); s = (sptr ? sptr->size() : 0); + if (sptr) inc_ref(sptr); + } + BOOST_SERIALIZATION_SPLIT_MEMBER(); }; }}}//namespace