Skip to content

Commit

Permalink
Avoid memory allocation in Ethernet callbacks
Browse files Browse the repository at this point in the history
std::bind can cause a memory allocation to occur during the periodic
polling interrupt which is a very bad thing.  Use a lambda instead.

Fixes #1812
  • Loading branch information
earlephilhower committed Nov 13, 2023
1 parent db7ba16 commit 0ded4e6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libraries/lwIP_Ethernet/src/LwipIntfDev.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ bool LwipIntfDev<RawDev>::begin(const uint8_t* macAddress, const uint16_t mtu) {
return false;
}

_phID = __addEthernetPacketHandler(std::bind(&LwipIntfDev<RawDev>::handlePackets, this));
_phID = __addEthernetPacketHandler([this]{ this->handlePackets(); });

if (localIP().v4() == 0) {
// IP not set, starting DHCP
Expand Down

0 comments on commit 0ded4e6

Please sign in to comment.