Pages: [1]   Go Down
Author Topic: Where do I submit a bug fix to Ethernet.cpp?  (Read 1173 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There is a memory leak in Ethernet.cpp (for version arduino-1.0.1).
I have a patch. What is the procedure for submitting the patch upstream?

Basically, each call to EthernetClass::begin will create a new DhcpClass.
The _dhcp member variable is never deleted, so each subsequent call to
EthernetClass::begin will leak about 100 bytes. It takes about 10 calls to
EthernetClass::begin to cause the Atmega328 to run out of memory.
My patch simply checks if _dhcp was already allocated;
if allocated then it reuses the previously allocated _dhcp.
This may not be the best way to handle this case, but it
works in my application and it seems to not cause any trouble in
the examples included with the Ethernet library.

$ diff -up Ethernet.cpp Ethernet-noah.cpp 
--- Ethernet.cpp   2012-03-11 14:30:32.000000000 -0700
+++ Ethernet-noah.cpp   2012-07-30 19:25:24.353578643 -0700
@@ -10,8 +10,9 @@ uint16_t EthernetClass::_server_port[MAX
 
 int EthernetClass::begin(uint8_t *mac_address)
 {
-  _dhcp = new DhcpClass();
-
+   if (_dhcp == NULL) {
+     _dhcp = new DhcpClass();
+   }
 
   // Initialise the basic info
   W5100.init();
@@ -89,6 +90,8 @@ int EthernetClass::maintain(){
         break;
     }
   }
+// else maybe do something if _dhcp is NULL?
+
   return rc;
 }



--
Noah Spurrier <noah@noah.org>

Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 209
Posts: 13024
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Be back in a minute with the complete answer...
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 209
Posts: 13024
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Give this a read...
http://code.google.com/p/arduino/wiki/DevelopmentPolicy

Patches submitted as GitHub pull requests seem to be the most likely to be applied.
Logged

Pages: [1]   Go Up
Jump to: