Skip to content

Commit 3f49281

Browse files
Merge pull request #99 from martinayotte/master
Fix bug about DhcpClass instantiation to save 40K by avoiding link with GCC 'new' memory allocation code
2 parents f3c46b0 + c70df49 commit 3f49281

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

STM32F4/libraries/arduino_uip/UIPEthernet.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ DhcpClass* UIPEthernetClass::_dhcp(NULL);
4949

5050
unsigned long UIPEthernetClass::periodic_timer;
5151

52+
static DhcpClass s_dhcp; // Placing this instance here is saving 40K to final *.bin (see bug below)
53+
54+
5255
// Because uIP isn't encapsulated within a class we have to use global
5356
// variables, so we can only have one TCP/IP stack per program.
5457

@@ -60,7 +63,8 @@ UIPEthernetClass::UIPEthernetClass()
6063
int
6164
UIPEthernetClass::begin(const uint8_t* mac)
6265
{
63-
static DhcpClass s_dhcp;
66+
//static DhcpClass s_dhcp; // <-- this is a bug !
67+
// I leave it there commented for history. It is bring all GCC "new" memory allocation code, making the *.bin almost 40K bigger. I've move it globally.
6468
_dhcp = &s_dhcp;
6569
// Initialise the basic info
6670
init(mac);

0 commit comments

Comments
 (0)