summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2014-01-08 22:36:37 +0000
committermillert <millert@openbsd.org>2014-01-08 22:36:37 +0000
commitf6169c9ed6db5ac49873a82567414e6c3146a655 (patch)
tree4e69e9cfc251a2100ac0506abc06e6ba647d774d
parentMake allocate() take size_t and return void *. This lets us drop (diff)
downloadwireguard-openbsd-f6169c9ed6db5ac49873a82567414e6c3146a655.tar.xz
wireguard-openbsd-f6169c9ed6db5ac49873a82567414e6c3146a655.zip
Use calloc() instead of malloc() + memset. Based on a diff from
Michael W. Bombardieri. OK deraadt@
-rw-r--r--usr.bin/yacc/lr0.c6
-rw-r--r--usr.bin/yacc/output.c7
2 files changed, 4 insertions, 9 deletions
diff --git a/usr.bin/yacc/lr0.c b/usr.bin/yacc/lr0.c
index 10e4b2146c4..6ac2e91998e 100644
--- a/usr.bin/yacc/lr0.c
+++ b/usr.bin/yacc/lr0.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lr0.c,v 1.14 2014/01/08 22:30:32 millert Exp $ */
+/* $OpenBSD: lr0.c,v 1.15 2014/01/08 22:36:37 millert Exp $ */
/* $NetBSD: lr0.c,v 1.4 1996/03/19 03:21:35 jtc Exp $ */
/*
@@ -510,11 +510,9 @@ set_nullable(void)
int empty;
int done;
- nullable = malloc(nsyms);
+ nullable = calloc(1, nsyms);
if (nullable == 0) no_space();
- memset(nullable, 0, nsyms);
-
done = 0;
while (!done)
{
diff --git a/usr.bin/yacc/output.c b/usr.bin/yacc/output.c
index 520ef546461..dd00477248f 100644
--- a/usr.bin/yacc/output.c
+++ b/usr.bin/yacc/output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: output.c,v 1.17 2014/01/08 21:40:25 millert Exp $ */
+/* $OpenBSD: output.c,v 1.18 2014/01/08 22:36:37 millert Exp $ */
/* $NetBSD: output.c,v 1.4 1996/03/19 03:21:41 jtc Exp $ */
/*
@@ -996,12 +996,9 @@ output_debug(void)
++outline;
fprintf(code_file, "#define YYMAXTOKEN %d\n", max);
- symnam = (char **) malloc((max+1)*sizeof(char *));
+ symnam = (char **) calloc(max+1, sizeof(char *));
if (symnam == 0) no_space();
- /* Note that it is not necessary to initialize the element */
- /* symnam[max]. */
- memset(symnam, 0, max * sizeof(char *));
for (i = ntokens - 1; i >= 2; --i)
symnam[symbol_value[i]] = symbol_name[i];
symnam[0] = "end-of-file";