Skip to content

Commit

Permalink
Delete query and answer list in destructor
Browse files Browse the repository at this point in the history
  • Loading branch information
larsenglund committed Mar 10, 2016
1 parent 042fa10 commit 609c84b
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion libraries/ESP8266mDNS/ESP8266mDNS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,23 @@ MDNSResponder::MDNSResponder() : _conn(0) {
_newQuery = false;
_waitingForAnswers = false;
}
MDNSResponder::~MDNSResponder() {}
MDNSResponder::~MDNSResponder() {
if (_query != 0) {
os_free(_query);
_query = 0;
}

// Clear answer list
MDNSAnswer *answer;
int numAnswers = _getNumAnswers();
for (int n = numAnswers - 1; n >= 0; n--) {
answer = _getAnswerFromIdx(n);
os_free(answer->hostname);
os_free(answer);
answer = 0;
}
_answers = 0;
}

bool MDNSResponder::begin(const char* hostname){
// Open the MDNS socket if it isn't already open.
Expand Down

0 comments on commit 609c84b

Please sign in to comment.