Fixed an error with the destructors. valgrind showed that destructor
wasn't being called for single instance of FalloffFactory.
This commit is contained in:
parent
5cd6d39c39
commit
e793a0c76d
2 changed files with 11 additions and 10 deletions
|
|
@ -102,11 +102,13 @@ namespace Cantera {
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete the factory, and set the pointer to zero.
|
||||
* Destructor doesn't do anything. We do not delete statically
|
||||
* created single instance of this class here, because it would
|
||||
* create an infinite loop if destructor is called for that
|
||||
* single instance. Instead, to delete single instance, we
|
||||
* call delete[] from FalloffMng's destructor.
|
||||
*/
|
||||
virtual ~FalloffFactory() {
|
||||
delete __factory;
|
||||
__factory = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@ namespace Cantera {
|
|||
* falloff function calculators. If omitted, the standard factory
|
||||
* will be used.
|
||||
*/
|
||||
FalloffMgr(FalloffFactory* f = 0) : m_n(0), m_n0(0), m_worksize(0) {
|
||||
FalloffMgr(FalloffFactory* f = 0) :
|
||||
m_factory(0), m_n(0), m_n0(0), m_worksize(0) {
|
||||
if (f == 0) m_factory = FalloffFactory::factory();
|
||||
else m_factory = f;
|
||||
}
|
||||
|
|
@ -42,6 +43,10 @@ namespace Cantera {
|
|||
virtual ~FalloffMgr(){
|
||||
int i;
|
||||
for (i = 0; i < m_n; i++) delete m_falloff[i];
|
||||
if (m_factory) {
|
||||
delete m_factory;
|
||||
m_factory = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -114,9 +119,3 @@ namespace Cantera {
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue