Skip to content

Commit 4625d2c

Browse files
Avoid memory allocation in Ethernet callbacks (earlephilhower#1815)
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 earlephilhower#1812
1 parent db7ba16 commit 4625d2c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libraries/lwIP_Ethernet/src/LwipIntfDev.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ bool LwipIntfDev<RawDev>::begin(const uint8_t* macAddress, const uint16_t mtu) {
310310
return false;
311311
}
312312

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

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

0 commit comments

Comments
 (0)