anilgkts / arduino

Automatically exported from code.google.com/p/arduino
Other
0 stars 0 forks source link

Ethernet DHCP library code size #863

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
As discussed on the developers mailing list:

http://arduino.cc/pipermail/developers_arduino.cc/2012-March/006358.html

Changes to the Ethernet DHCP library between 1.0 and 1.0.1rc1 have resulted in 
the code being larger and consuming more RAM.

<sketch> = <compiled size>, <free ram>

IDE 1.0:

No ethernet = 6826, 1236
Static IP = 8598, 1142
DHCP IP = 15040, 1090

IDE 1.0.1rc1:

No ethernet = 6714, 1236
Static IP = 8536, 1140
DHCP IP = 16470, 982

Those numbers further deteriorate if the new "maintain()" method is used. 

Once specific concern is the use of "new" to create an instance of the 
DHCPClass. I'd like to suggest the following change to Ethernet.cpp:

 int EthernetClass::begin(uint8_t *mac_address)
 {
-  _dhcp = new DhcpClass();

+  static DhcpClass dhcp;
+  _dhcp = &dhcp;

This change saves almost 500 bytes of code. It has no impact on RAM use. 

I've given the change some superficial testing and it seems to work. 

Thanks,

Dylan

Original issue reported on code.google.com by dy...@deedums.com on 19 Mar 2012 at 9:27

GoogleCodeExporter commented 9 years ago
This has been fixed long time ago:

https://github.com/arduino/Arduino/commit/cce70d269c23e9985fe970378fb6dd209b5766
43

Original comment by c.mag...@arduino.cc on 4 Jun 2015 at 6:05