Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/stdlib use calloc rather than malloc + memset 0
details: https://anonhg.NetBSD.org/src/rev/2e1659a2ce39
branches: trunk
changeset: 357789:2e1659a2ce39
user: maya <maya%NetBSD.org@localhost>
date: Mon Nov 27 23:54:28 2017 +0000
description:
use calloc rather than malloc + memset 0
diffstat:
lib/libc/stdlib/strfmon.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diffs (32 lines):
diff -r 7034ec70e4d2 -r 2e1659a2ce39 lib/libc/stdlib/strfmon.c
--- a/lib/libc/stdlib/strfmon.c Mon Nov 27 22:43:07 2017 +0000
+++ b/lib/libc/stdlib/strfmon.c Mon Nov 27 23:54:28 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: strfmon.c,v 1.12 2017/11/27 22:43:07 christos Exp $ */
+/* $NetBSD: strfmon.c,v 1.13 2017/11/27 23:54:28 maya Exp $ */
/*-
* Copyright (c) 2001 Alexey Zelkin <phantom%FreeBSD.org@localhost>
@@ -32,7 +32,7 @@
#if 0
__FBSDID("$FreeBSD: src/lib/libc/stdlib/strfmon.c,v 1.14 2003/03/20 08:18:55 ache Exp $");
#else
-__RCSID("$NetBSD: strfmon.c,v 1.12 2017/11/27 22:43:07 christos Exp $");
+__RCSID("$NetBSD: strfmon.c,v 1.13 2017/11/27 23:54:28 maya Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -556,12 +556,11 @@
/* make sure that we've enough space for result string */
bufsize = avalue_size * 2 + 1;
- rslt = malloc(bufsize);
+ rslt = calloc(1, bufsize);
if (rslt == NULL) {
free(avalue);
return (NULL);
}
- memset(rslt, 0, bufsize);
bufend = rslt + bufsize - 1; /* reserve space for trailing '\0' */
/* skip spaces at beggining */
Home |
Main Index |
Thread Index |
Old Index