From 42c193821cf8cdd8ae09362c3e00fd2fde480540 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Mon, 22 Aug 2016 22:08:34 +0800 Subject: [PATCH] netbuf: Use memset to zero the allocated memory for netbuf_new Use memset to zero the allocated memory rather than explicitly init each field. Signed-off-by: Axel Lin Signed-off-by: goldsimon --- src/api/netbuf.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/api/netbuf.c b/src/api/netbuf.c index 50625167..8d2cd1b7 100644 --- a/src/api/netbuf.c +++ b/src/api/netbuf.c @@ -66,23 +66,9 @@ netbuf *netbuf_new(void) buf = (struct netbuf *)memp_malloc(MEMP_NETBUF); if (buf != NULL) { - buf->p = NULL; - buf->ptr = NULL; - ip_addr_set_zero(&buf->addr); - buf->port = 0; -#if LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY -#if LWIP_CHECKSUM_ON_COPY - buf->flags = 0; -#endif /* LWIP_CHECKSUM_ON_COPY */ - buf->toport_chksum = 0; -#if LWIP_NETBUF_RECVINFO - ip_addr_set_zero(&buf->toaddr); -#endif /* LWIP_NETBUF_RECVINFO */ -#endif /* LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY */ - return buf; - } else { - return NULL; + memset(buf, 0, sizeof(struct netbuf)); } + return buf; } /**