Skip to content

Commit 8beb439

Browse files
authored
Update ethernetif.c
1 parent 4f53c68 commit 8beb439

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -494,20 +494,15 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_
494494
#if LWIP_NETIF_HOSTNAME
495495
#define LWIP_HOSTNAME_LEN 16
496496
char *hostname = RT_NULL;
497-
netif = (struct netif*) rt_malloc (sizeof(struct netif) + LWIP_HOSTNAME_LEN);
497+
netif = (struct netif*) rt_calloc (1, sizeof(struct netif) + LWIP_HOSTNAME_LEN);
498498
#else
499-
netif = (struct netif*) rt_malloc (sizeof(struct netif));
499+
netif = (struct netif*) rt_calloc (1, sizeof(struct netif));
500500
#endif
501501
if (netif == RT_NULL)
502502
{
503503
rt_kprintf("malloc netif failed\n");
504504
return -RT_ERROR;
505505
}
506-
#if LWIP_NETIF_HOSTNAME
507-
rt_memset(netif, 0, sizeof(struct netif)+ LWIP_HOSTNAME_LEN);
508-
#else
509-
rt_memset(netif, 0, sizeof(struct netif));
510-
#endif
511506

512507
/* set netif */
513508
dev->netif = netif;

0 commit comments

Comments
 (0)