more cleanup
This commit is contained in:
parent
b3f6f01d97
commit
0329d32b49
|
@ -9,7 +9,6 @@ EventMatchTree::EventMatchTree(StorageManagerIF* storageBackend, bool invertedMa
|
|||
: MatchTree<EventMessage*>(end(), 1), factory(storageBackend), invertedMatch(invertedMatch) {
|
||||
}
|
||||
|
||||
#include <stdio.h>
|
||||
EventMatchTree::~EventMatchTree() {}
|
||||
|
||||
bool EventMatchTree::match(EventMessage* number) {
|
||||
|
|
|
@ -31,10 +31,9 @@ void ObjectManager::clear() {
|
|||
}
|
||||
|
||||
ObjectManager::~ObjectManager() {
|
||||
auto iter = objectList.begin();
|
||||
while (iter != objectList.end()) {
|
||||
teardown = true;
|
||||
for (auto iter = objectList.begin(); iter != objectList.end(); iter = objectList.erase(iter)) {
|
||||
delete iter->second;
|
||||
iter = objectList.begin();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,6 +61,12 @@ ReturnValue_t ObjectManager::insert(object_id_t id, SystemObjectIF* object) {
|
|||
}
|
||||
|
||||
ReturnValue_t ObjectManager::remove(object_id_t id) {
|
||||
// this function is called during destruction of System Objects
|
||||
// disabeld for teardown to avoid iterator invalidation and
|
||||
// double free
|
||||
if (teardown) {
|
||||
return returnvalue::OK;
|
||||
}
|
||||
if (this->getSystemObject(id) != nullptr) {
|
||||
this->objectList.erase(id);
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
|
|
|
@ -71,6 +71,9 @@ class ObjectManager : public ObjectManagerIF {
|
|||
*/
|
||||
std::map<object_id_t, SystemObjectIF*> objectList;
|
||||
static ObjectManager* objManagerInstance;
|
||||
// used when the OM itself is deleted to modify behaviour of remove()
|
||||
// to avoid iterator invalidation and double free
|
||||
bool teardown = false;
|
||||
};
|
||||
|
||||
// Documentation can be found in the class method declaration above
|
||||
|
|
Loading…
Reference in New Issue
Block a user