Fix delete was not really deleting in tinytest

This commit is contained in:
hsaturn
2021-03-31 10:36:51 +02:00
parent 3a1af655d7
commit 549a23ffb7
2 changed files with 3 additions and 2 deletions

View File

@@ -399,11 +399,11 @@ void loop()
} }
if (client) if (client)
{ {
clients.erase(s);
for (auto it: clients) for (auto it: clients)
{ {
if (it.second != client) continue; if (it.second != client) continue;
Serial << "deleted" << endl; Serial << "deleted" << endl;
delete (it.second);
clients.erase(it.first); clients.erase(it.first);
break; break;
} }
@@ -413,9 +413,9 @@ void loop()
{ {
for(auto it: brokers) for(auto it: brokers)
{ {
Serial << (int32_t)it.second << '/' << (int32_t)broker << endl;
if (broker != it.second) continue; if (broker != it.second) continue;
Serial << "deleted" << endl; Serial << "deleted" << endl;
delete (it.second);
brokers.erase(it.first); brokers.erase(it.first);
break; break;
} }

View File

@@ -19,6 +19,7 @@ MqttBroker::~MqttBroker()
{ {
delete clients[0]; delete clients[0];
} }
server.close();
} }
// private constructor used by broker only // private constructor used by broker only