Skip to content

Commit 822df76

Browse files
authored
Update ethernetif.c
1 parent aa0b68a commit 822df76

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

components/net/lwip-2.1.0/src/netif/ethernetif.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -490,20 +490,15 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_
490490
#if LWIP_NETIF_HOSTNAME
491491
#define LWIP_HOSTNAME_LEN 16
492492
char *hostname = RT_NULL;
493-
netif = (struct netif*) rt_malloc (sizeof(struct netif) + LWIP_HOSTNAME_LEN);
493+
netif = (struct netif*) rt_calloc (1, sizeof(struct netif) + LWIP_HOSTNAME_LEN);
494494
#else
495-
netif = (struct netif*) rt_malloc (sizeof(struct netif));
495+
netif = (struct netif*) rt_calloc (1, sizeof(struct netif));
496496
#endif
497497
if (netif == RT_NULL)
498498
{
499499
rt_kprintf("malloc netif failed\n");
500500
return -RT_ERROR;
501501
}
502-
#if LWIP_NETIF_HOSTNAME
503-
rt_memset(netif, 0, sizeof(struct netif) + LWIP_HOSTNAME_LEN);
504-
#else
505-
rt_memset(netif, 0, sizeof(struct netif));
506-
#endif
507502

508503
/* set netif */
509504
dev->netif = netif;

0 commit comments

Comments
 (0)