Try to remove #include <stdlib.h> from many files. Does not seem necessary any more and might cause problems when porting lwIP.
diff --git a/src/api/netdb.c b/src/api/netdb.c
index 55f2f76..ac1d8c7 100644
--- a/src/api/netdb.c
+++ b/src/api/netdb.c
@@ -47,7 +47,6 @@
 #include "lwip/dns.h"
 
 #include <string.h>
-#include <stdlib.h>
 
 /** helper struct for gethostbyname_r to access the char* buffer */
 struct gethostbyname_r_helper {
diff --git a/src/apps/httpd/httpd.c b/src/apps/httpd/httpd.c
index 103f9ac..2c836c8 100644
--- a/src/apps/httpd/httpd.c
+++ b/src/apps/httpd/httpd.c
@@ -99,7 +99,6 @@
 #include "lwip/tcp.h"
 
 #include <string.h>
-#include <stdlib.h>
 #include <stdio.h>
 
 #if LWIP_TCP
diff --git a/src/apps/mdns/mdns.c b/src/apps/mdns/mdns.c
index c140185..e90c544 100644
--- a/src/apps/mdns/mdns.c
+++ b/src/apps/mdns/mdns.c
@@ -65,7 +65,6 @@
 #include "lwip/prot/dns.h"
 
 #include <string.h>
-#include <stdlib.h>
 
 #if LWIP_MDNS_RESPONDER
 
diff --git a/src/core/ipv4/autoip.c b/src/core/ipv4/autoip.c
index 9aa3283..c5426ea 100644
--- a/src/core/ipv4/autoip.c
+++ b/src/core/ipv4/autoip.c
@@ -68,7 +68,6 @@
 #include "lwip/etharp.h"
 #include "lwip/prot/autoip.h"
 
-#include <stdlib.h>
 #include <string.h>
 
 /** Pseudo random macro based on netif informations.
diff --git a/src/core/mem.c b/src/core/mem.c
index 40f4cb9..9908c02 100644
--- a/src/core/mem.c
+++ b/src/core/mem.c
@@ -61,9 +61,13 @@
 #include "lwip/err.h"
 
 #include <string.h>
-#include <stdlib.h>
+
+#if MEM_LIBC_MALLOC
+#include <stdlib.h> /* for malloc()/free() */
+#endif
 
 #if MEM_LIBC_MALLOC || MEM_USE_POOLS
+
 /** mem_init is not used when using pools instead of a heap or using
  * C library malloc().
  */