Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/disklabel disklabel(8): convert malloc(x * y) to reallo...
details: https://anonhg.NetBSD.org/src/rev/353c8aa204bf
branches: trunk
changeset: 1024767:353c8aa204bf
user: nia <nia%NetBSD.org@localhost>
date: Wed Nov 03 14:25:39 2021 +0000
description:
disklabel(8): convert malloc(x * y) to reallocarr
diffstat:
sbin/disklabel/interact.c | 10 +++++-----
sbin/disklabel/main.c | 9 ++++-----
2 files changed, 9 insertions(+), 10 deletions(-)
diffs (64 lines):
diff -r 85902048e78f -r 353c8aa204bf sbin/disklabel/interact.c
--- a/sbin/disklabel/interact.c Wed Nov 03 08:05:39 2021 +0000
+++ b/sbin/disklabel/interact.c Wed Nov 03 14:25:39 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: interact.c,v 1.39 2016/01/31 18:57:29 christos Exp $ */
+/* $NetBSD: interact.c,v 1.40 2021/11/03 14:25:39 nia Exp $ */
/*
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: interact.c,v 1.39 2016/01/31 18:57:29 christos Exp $");
+__RCSID("$NetBSD: interact.c,v 1.40 2021/11/03 14:25:39 nia Exp $");
#endif /* lint */
#include <sys/param.h>
@@ -674,10 +674,10 @@
size_t i, entry, lines;
int columns, width;
const char *p;
- const char **list;
+ const char **list = NULL;
- if ((list = (const char **)malloc(sizeof(char *) * numentries)) == NULL)
- err(1, "malloc");
+ if (reallocarr(&list, numentries, sizeof(char *)) != 0)
+ err(1, "reallocarr");
width = 0;
printf("%s:\n", prompt);
for (i = 0; i < numentries; i++) {
diff -r 85902048e78f -r 353c8aa204bf sbin/disklabel/main.c
--- a/sbin/disklabel/main.c Wed Nov 03 08:05:39 2021 +0000
+++ b/sbin/disklabel/main.c Wed Nov 03 14:25:39 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.56 2021/05/29 17:41:51 christos Exp $ */
+/* $NetBSD: main.c,v 1.57 2021/11/03 14:25:39 nia Exp $ */
/*
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -76,7 +76,7 @@
static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95";
/* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */
#else
-__RCSID("$NetBSD: main.c,v 1.56 2021/05/29 17:41:51 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.57 2021/11/03 14:25:39 nia Exp $");
#endif
#endif /* not lint */
@@ -2207,11 +2207,10 @@
ret = 1;
if (nelems > 0) {
- const char **list;
+ const char **list = NULL;
size_t i;
- list = (const char **)malloc(sizeof(char *) * nelems);
- if (list == NULL) {
+ if (reallocarr(&list, nelems, sizeof(char *)) != 0) {
warnx("sorry, could not allocate memory for list");
ret = 0;
} else {
Home |
Main Index |
Thread Index |
Old Index