From aa0b68a57594a77ec9701cc89422ae461a0e4c3d Mon Sep 17 00:00:00 2001 From: David Lin Date: Wed, 10 Jun 2020 23:30:44 +0800 Subject: [PATCH] Update ethernetif.c --- components/net/lwip-1.4.1/src/netif/ethernetif.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/components/net/lwip-1.4.1/src/netif/ethernetif.c b/components/net/lwip-1.4.1/src/netif/ethernetif.c index 85ac09524b..d31ea813bc 100644 --- a/components/net/lwip-1.4.1/src/netif/ethernetif.c +++ b/components/net/lwip-1.4.1/src/netif/ethernetif.c @@ -443,20 +443,15 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_ #if LWIP_NETIF_HOSTNAME #define LWIP_HOSTNAME_LEN 16 char *hostname = RT_NULL; - netif = (struct netif*) rt_malloc (sizeof(struct netif) + LWIP_HOSTNAME_LEN); + netif = (struct netif*) rt_calloc (1, sizeof(struct netif) + LWIP_HOSTNAME_LEN); #else - netif = (struct netif*) rt_malloc (sizeof(struct netif)); + netif = (struct netif*) rt_calloc (1, sizeof(struct netif)); #endif if (netif == RT_NULL) { rt_kprintf("malloc netif failed\n"); return -RT_ERROR; } -#if LWIP_NETIF_HOSTNAME - rt_memset(netif, 0, sizeof(struct netif) + LWIP_HOSTNAME_LEN); -#else - rt_memset(netif, 0, sizeof(struct netif)); -#endif /* set netif */ dev->netif = netif; -- GitLab