On 12/31/16 16:00, Ngie Cooper wrote:
Author: ngie
Date: Sat Dec 31 21:00:08 2016
New Revision: 310984
URL: https://svnweb.freebsd.org/changeset/base/310984

Log:
  Use calloc instead of malloc + memset(.., 0, ..)

  MFC after:    1 week

Modified:
  head/lib/libc/net/getaddrinfo.c

Modified: head/lib/libc/net/getaddrinfo.c
==============================================================================
--- head/lib/libc/net/getaddrinfo.c     Sat Dec 31 19:59:31 2016        
(r310983)
+++ head/lib/libc/net/getaddrinfo.c     Sat Dec 31 21:00:08 2016        
(r310984)
@@ -691,9 +691,8 @@ reorder(struct addrinfo *sentinel)
                return(n);

        /* allocate a temporary array for sort and initialization of it. */
-       if ((aio = malloc(sizeof(*aio) * n)) == NULL)
+       if ((aio = calloc(1, sizeof(*aio) * n)) == NULL)
                return(n);      /* give up reordering */

This should be calloc(n, sizeof(*aio)))

FWIW, the other cases are not very useful.
Generally, replacing any malloc(x) with a calloc(1, x) doesn't bring any advantage as it won't catch any overflow.

Pedro.
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to