Skip to content

Commit cfd9889

Browse files
committed
Imported Ehternet memory-leak fix into sam
1 parent 1da3752 commit cfd9889

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

hardware/arduino/sam/libraries/Ethernet/Dhcp.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ int DhcpClass::request_DHCP_lease(){
4343
_dhcpTransactionId = random(1UL, 2000UL);
4444
_dhcpInitialTransactionId = _dhcpTransactionId;
4545

46+
_dhcpUdpSocket.stop();
4647
if (_dhcpUdpSocket.begin(DHCP_CLIENT_PORT) == 0)
4748
{
4849
// Couldn't get a socket

hardware/arduino/sam/libraries/Ethernet/Ethernet.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ uint16_t EthernetClass::_server_port[MAX_SOCK_NUM] = {
1010

1111
int EthernetClass::begin(uint8_t *mac_address)
1212
{
13-
_dhcp = new DhcpClass();
13+
static DhcpClass s_dhcp;
14+
_dhcp = &s_dhcp;
15+
1416

1517
// Initialise the basic info
1618
W5100.init();
@@ -59,7 +61,6 @@ void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dn
5961
void EthernetClass::begin(uint8_t *mac, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet)
6062
{
6163
W5100.init();
62-
6364
W5100.setMACAddress(mac);
6465
W5100.setIPAddress(local_ip._address);
6566
W5100.setGatewayIp(gateway._address);

0 commit comments

Comments
 (0)