From eb98ed9ce24304839b54bc8c0a2e3763438fb0c4 Mon Sep 17 00:00:00 2001 From: Pawel Szostek Date: Wed, 20 Jul 2011 18:16:08 +0200 Subject: [PATCH] Add additional deletion in VHDL classes' destructors Delete dynamically allocated objects in ScopeBase, Architecture, ComponentInstatiation, Entity and Package. --- vhdlpp/architec.cc | 5 +++++ vhdlpp/entity.cc | 6 ++++++ vhdlpp/package.cc | 1 + 3 files changed, 12 insertions(+) diff --git a/vhdlpp/architec.cc b/vhdlpp/architec.cc index b3e5cfc4f..580b030a0 100644 --- a/vhdlpp/architec.cc +++ b/vhdlpp/architec.cc @@ -32,6 +32,8 @@ Architecture::Architecture(perm_string name, const ScopeBase&ref, Architecture::~Architecture() { + delete_all(statements_); + ScopeBase::cleanup(); } Architecture::Statement::Statement() @@ -75,6 +77,9 @@ ComponentInstantiation::ComponentInstantiation(perm_string i, perm_string c, ComponentInstantiation::~ComponentInstantiation() { + for(map::iterator it = port_map_.begin() + ; it != port_map_.end(); ++it) + delete it->second; } ProcessStatement::ProcessStatement(perm_string iname, diff --git a/vhdlpp/entity.cc b/vhdlpp/entity.cc index b9ccbff0a..de3846fb2 100644 --- a/vhdlpp/entity.cc +++ b/vhdlpp/entity.cc @@ -33,6 +33,9 @@ ComponentBase::ComponentBase(perm_string name) ComponentBase::~ComponentBase() { + for(std::vector::iterator it = ports_.begin() + ; it != ports_.end(); ++it) + delete *it; } void ComponentBase::set_interface(std::list*ports) @@ -60,6 +63,9 @@ Entity::Entity(perm_string name) Entity::~Entity() { + for(map::reverse_iterator it = arch_.rbegin() + ; it != arch_.rend(); ++it) + delete it->second; } Architecture* Entity::add_architecture(Architecture*that) diff --git a/vhdlpp/package.cc b/vhdlpp/package.cc index 936464569..f36c0b46f 100644 --- a/vhdlpp/package.cc +++ b/vhdlpp/package.cc @@ -26,4 +26,5 @@ Package::Package(perm_string n, const ScopeBase&ref) Package::~Package() { + ScopeBase::cleanup(); }