10000 Frees the memory used by the event handler on destruction · Tomato1107/esp32-snippets@fbc7022 · GitHub
[go: up one dir, main page]

Skip to content

Commit fbc7022

Browse files
committed
Frees the memory used by the event handler on destruction
Also a small optimization in the WiFi constructor
1 parent 8c2ab32 commit fbc7022

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

cpp_utils/WiFi.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,27 @@ static void setDNSServer(char *ip) {
4242
*/
4343

4444

45-
WiFi::WiFi() {
46-
ip = "";
47-
gw = "";
48-
netmask = "";
45+
}
46+
*/
47+
48+
/**
49+
* @brief Creates and uses a default event handler
50+
*/
51+
WiFi::WiFi()
52+
: ip("")
53+
, gw("")
54+
, netmask("")
55+
, wifiEventHandler(nullptr)
56+
{
4957
wifiEventHandler = new WiFiEventHandler();
5058
}
5159

60+
/**
61+
* @brief Deletes the event handler that was used by the class
62+
*/
63+
WiFi::~WiFi() {
64+
delete wifiEventHandler;
65+
}
5266

5367
/**
5468
* @brief Add a reference to a DNS server.

cpp_utils/WiFi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ class WiFi {
110110

111111
public:
112112
WiFi();
113+
~WiFi();
113114
void addDNSServer(const std::string& ip);
114115
void addDNSServer(const char* ip);
115116
void setDNSServer(int numdns, const std::string& ip);

0 commit comments

Comments
 (0)
0