Merge fix/memory-leaks: Add destructor, init pointers to nullptr
This commit is contained in:
commit
dd881f79f3
@ -733,6 +733,21 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
|
|||||||
_prefs.adc_multiplier = 0.0f; // 0.0f means use default board multiplier
|
_prefs.adc_multiplier = 0.0f; // 0.0f means use default board multiplier
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MyMesh::~MyMesh() {
|
||||||
|
// Clean up dynamically allocated resources
|
||||||
|
#ifdef WITH_MQTT
|
||||||
|
delete _web_config;
|
||||||
|
_web_config = nullptr;
|
||||||
|
delete _mqtt_bridge;
|
||||||
|
_mqtt_bridge = nullptr;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WITH_ETHERNET
|
||||||
|
delete _mqtt_bridge;
|
||||||
|
_mqtt_bridge = nullptr;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void MyMesh::begin(FILESYSTEM *fs) {
|
void MyMesh::begin(FILESYSTEM *fs) {
|
||||||
mesh::Mesh::begin();
|
mesh::Mesh::begin();
|
||||||
_fs = fs;
|
_fs = fs;
|
||||||
|
|||||||
11
src/MyMesh.h
11
src/MyMesh.h
@ -125,21 +125,21 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
|
|||||||
|
|
||||||
#ifdef WITH_MQTT
|
#ifdef WITH_MQTT
|
||||||
WiFiManager _wifi_mgr;
|
WiFiManager _wifi_mgr;
|
||||||
MQTTBridge* _mqtt_bridge;
|
MQTTBridge* _mqtt_bridge = nullptr;
|
||||||
WebConfig* _web_config;
|
WebConfig* _web_config = nullptr;
|
||||||
WiFiConfig _wifi_config;
|
WiFiConfig _wifi_config;
|
||||||
MQTTConfig _mqtt_config;
|
MQTTConfig _mqtt_config;
|
||||||
unsigned long _last_mqtt_stats;
|
unsigned long _last_mqtt_stats = 0;
|
||||||
|
|
||||||
void initMQTT();
|
void initMQTT();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WITH_ETHERNET
|
#ifdef WITH_ETHERNET
|
||||||
EthernetManager _eth_mgr;
|
EthernetManager _eth_mgr;
|
||||||
MQTTBridge* _mqtt_bridge;
|
MQTTBridge* _mqtt_bridge = nullptr;
|
||||||
MQTTConfig _mqtt_config;
|
MQTTConfig _mqtt_config;
|
||||||
EthernetConfig _eth_config;
|
EthernetConfig _eth_config;
|
||||||
unsigned long _last_mqtt_stats;
|
unsigned long _last_mqtt_stats = 0;
|
||||||
|
|
||||||
void initEthernet();
|
void initEthernet();
|
||||||
#endif
|
#endif
|
||||||
@ -196,6 +196,7 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
MyMesh(mesh::MainBoard& board, mesh::Radio& radio, mesh::MillisecondClock& ms, mesh::RNG& rng, mesh::RTCClock& rtc, mesh::MeshTables& tables);
|
MyMesh(mesh::MainBoard& board, mesh::Radio& radio, mesh::MillisecondClock& ms, mesh::RNG& rng, mesh::RTCClock& rtc, mesh::MeshTables& tables);
|
||||||
|
~MyMesh(); // Clean up dynamically allocated resources
|
||||||
|
|
||||||
void begin(FILESYSTEM* fs);
|
void begin(FILESYSTEM* fs);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user