From 288b15d0793936fa14b51ed860056f6ce6200c52 Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Thu, 22 Jun 2017 08:26:27 -0400 Subject: Replace malloc+memset with calloc, mostly by using the new ezalloc macro. --- missing_d/ChangeLog | 4 ++++ missing_d/getaddrinfo.c | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'missing_d') diff --git a/missing_d/ChangeLog b/missing_d/ChangeLog index 83f5b93e..7d9bddc4 100644 --- a/missing_d/ChangeLog +++ b/missing_d/ChangeLog @@ -1,3 +1,7 @@ +2017-06-21 Andrew J. Schorr + + * getaddrinfo.c (getaddrinfo): Replace malloc+memset with calloc. + 2016-10-23 Arnold D. Robbins * General: Remove trailing whitespace from all relevant files. diff --git a/missing_d/getaddrinfo.c b/missing_d/getaddrinfo.c index f24ac598..5233cf56 100644 --- a/missing_d/getaddrinfo.c +++ b/missing_d/getaddrinfo.c @@ -33,12 +33,11 @@ getaddrinfo(const char *hostname, const char *portname, if (res == NULL) return EINVAL; - out = (struct addrinfo *) malloc(sizeof(*out)); + out = (struct addrinfo *) calloc(1, sizeof(*out)); if (out == NULL) { *res = NULL; return ENOMEM; } - memset(out, '\0', sizeof(*out)); out->ai_addr = (struct sockaddr *) malloc(sizeof(struct sockaddr_in)); if (out->ai_addr == NULL) { -- cgit v1.2.3