1. Fixed memory leak in shared_ptr loading

2. Fixed error in polymorphic archive implementation

[SVN r58258]
This commit is contained in:
Robert Ramey
2009-12-10 00:30:51 +00:00
parent a94e39ed5d
commit 4773b7d2a2
7 changed files with 138 additions and 64 deletions

View File

@@ -51,7 +51,6 @@ class basic_iarchive_impl {
friend class basic_iarchive;
version_type m_archive_library_version;
unsigned int m_flags;
const basic_iarchive * m_this;
//////////////////////////////////////////////////////////////////////
// information about each serialized object loaded
@@ -162,10 +161,9 @@ class basic_iarchive_impl {
const basic_iserializer * pending_bis;
version_type pending_version;
basic_iarchive_impl(const basic_iarchive * parent, unsigned int flags) :
basic_iarchive_impl(unsigned int flags) :
m_archive_library_version(BOOST_ARCHIVE_VERSION()),
m_flags(flags),
m_this(parent),
moveable_objects_start(0),
moveable_objects_end(0),
moveable_objects_recent(0),
@@ -214,7 +212,11 @@ class basic_iarchive_impl {
const basic_pointer_iserializer * load_pointer(
basic_iarchive & ar,
void * & t,
const basic_pointer_iserializer * bpis
const basic_pointer_iserializer * bpis,
const basic_pointer_iserializer * (*finder)(
const boost::serialization::extended_type_info & type
)
);
};
@@ -402,7 +404,11 @@ inline const basic_pointer_iserializer *
basic_iarchive_impl::load_pointer(
basic_iarchive &ar,
void * & t,
const basic_pointer_iserializer * bpis_ptr
const basic_pointer_iserializer * bpis_ptr,
const basic_pointer_iserializer * (*finder)(
const boost::serialization::extended_type_info & type_
)
){
class_id_type cid;
load(ar, cid);
@@ -435,7 +441,7 @@ basic_iarchive_impl::load_pointer(
boost::serialization::throw_exception(
archive_exception(archive_exception::unregistered_class)
);
bpis_ptr = m_this->find(*eti);
bpis_ptr = (*finder)(*eti);
}
assert(NULL != bpis_ptr);
class_id_type new_cid = register_type(bpis_ptr->get_basic_serializer());
@@ -511,7 +517,7 @@ basic_iarchive::next_object_pointer(void *t){
BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
basic_iarchive::basic_iarchive(unsigned int flags) :
pimpl(new basic_iarchive_impl(this, flags))
pimpl(new basic_iarchive_impl(flags))
{}
BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
@@ -545,9 +551,13 @@ basic_iarchive::load_object(
BOOST_ARCHIVE_DECL(const basic_pointer_iserializer *)
basic_iarchive::load_pointer(
void * &t,
const basic_pointer_iserializer * bpis_ptr
const basic_pointer_iserializer * bpis_ptr,
const basic_pointer_iserializer * (*finder)(
const boost::serialization::extended_type_info & type_
)
){
return pimpl->load_pointer(*this, t, bpis_ptr);
return pimpl->load_pointer(*this, t, bpis_ptr, finder);
}
BOOST_ARCHIVE_DECL(void)