Skip to content

Commit aa0b68a

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

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -443,20 +443,15 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_
443443
#if LWIP_NETIF_HOSTNAME
444444
#define LWIP_HOSTNAME_LEN 16
445445
char *hostname = RT_NULL;
446-
netif = (struct netif*) rt_malloc (sizeof(struct netif) + LWIP_HOSTNAME_LEN);
446+
netif = (struct netif*) rt_calloc (1, sizeof(struct netif) + LWIP_HOSTNAME_LEN);
447447
#else
448-
netif = (struct netif*) rt_malloc (sizeof(struct netif));
448+
netif = (struct netif*) rt_calloc (1, sizeof(struct netif));
449449
#endif
450450
if (netif == RT_NULL)
451451
{
452452
rt_kprintf("malloc netif failed\n");
453453
return -RT_ERROR;
454454
}
455-
#if LWIP_NETIF_HOSTNAME
456-
rt_memset(netif, 0, sizeof(struct netif) + LWIP_HOSTNAME_LEN);
457-
#else
458-
rt_memset(netif, 0, sizeof(struct netif));
459-
#endif
460455

461456
/* set netif */
462457
dev->netif = netif;

0 commit comments

Comments
 (0)