mirror of
git://sourceware.org/git/libabigail.git
synced 2025-03-07 15:17:39 +00:00
Remove circular ref from class_decl::priv::definition_of_declaration
It appears that there are cases where the data member class_decl::priv::definition_of_declaration_ can point to the current instance of class_decl, leading to a circular reference and thus a leak because the reference count of the current instance of class_decl will never reach zero. This patch fixes that by making class_decl::priv::definition_of_declaration_ be a weak pointer, rather than a smart pointer. * include/abg-ir.cc (class_decl::get_definition_of_declaration): Return a shared pointer, rather than a reference to a shared pointer. * src/abg-ir.cc (class_decl::priv::definition_of_declaration_): Make this be a weak pointer. (class_decl::get_definition_of_declaration): Likewise. And return the shared pointer built out of the weak pointer we have in there now. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
parent
b71e5c6f22
commit
5cf19e47ef
@ -3112,7 +3112,7 @@ public:
|
||||
void
|
||||
set_definition_of_declaration(class_decl_sptr);
|
||||
|
||||
const class_decl_sptr&
|
||||
const class_decl_sptr
|
||||
get_definition_of_declaration() const;
|
||||
|
||||
void
|
||||
|
@ -11490,7 +11490,7 @@ struct class_decl::priv
|
||||
bool is_declaration_only_;
|
||||
bool is_struct_;
|
||||
decl_base_sptr declaration_;
|
||||
class_decl_sptr definition_of_declaration_;
|
||||
class_decl_wptr definition_of_declaration_;
|
||||
base_specs bases_;
|
||||
unordered_map<string, base_spec_sptr> bases_map_;
|
||||
member_types member_types_;
|
||||
@ -11838,9 +11838,13 @@ class_decl::is_struct() const
|
||||
/// If this class is declaration-only, get its definition, if any.
|
||||
///
|
||||
/// @return the definition of this decl-only class.
|
||||
const class_decl_sptr&
|
||||
const class_decl_sptr
|
||||
class_decl::get_definition_of_declaration() const
|
||||
{return priv_->definition_of_declaration_;}
|
||||
{
|
||||
if (priv_->definition_of_declaration_.expired())
|
||||
return class_decl_sptr();
|
||||
return class_decl_sptr(priv_->definition_of_declaration_);
|
||||
}
|
||||
|
||||
/// If this class is a definitin, get its earlier declaration.
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user