summaryrefslogtreecommitdiff
path: root/sbin/ncheck_ffs/ncheck_ffs.c
diff options
context:
space:
mode:
authorAlexander Hall <halex@cvs.openbsd.org>2014-05-11 21:25:08 +0000
committerAlexander Hall <halex@cvs.openbsd.org>2014-05-11 21:25:08 +0000
commit2bf1d05cc7e0bebdb7eb1966925f39010be84b61 (patch)
tree25330d066715ea3f96634b71fd0e13fb319a019c /sbin/ncheck_ffs/ncheck_ffs.c
parent0512a443bd51ce081dfd705f272e71f50dca7634 (diff)
replace realloc(p, N * M) with reallocarray(p, N, M) and remove some
pointless cleanup if we're obviously going to die anyway ok guenther@
Diffstat (limited to 'sbin/ncheck_ffs/ncheck_ffs.c')
-rw-r--r--sbin/ncheck_ffs/ncheck_ffs.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/sbin/ncheck_ffs/ncheck_ffs.c b/sbin/ncheck_ffs/ncheck_ffs.c
index f398978fce1..48a8d79b49f 100644
--- a/sbin/ncheck_ffs/ncheck_ffs.c
+++ b/sbin/ncheck_ffs/ncheck_ffs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ncheck_ffs.c,v 1.39 2014/05/11 21:14:03 guenther Exp $ */
+/* $OpenBSD: ncheck_ffs.c,v 1.40 2014/05/11 21:25:07 halex Exp $ */
/*-
* Copyright (c) 1995, 1996 SigmaSoft, Th. Lockert <tholo@sigmasoft.com>
@@ -157,13 +157,9 @@ cacheino(ino_t ino, void *dp)
{
struct icache_s *newicache;
- newicache = realloc(icache, (nicache + 1) * sizeof(struct icache_s));
- if (newicache == NULL) {
- if (icache)
- free(icache);
- icache = NULL;
+ newicache = reallocarray(icache, nicache + 1, sizeof(struct icache_s));
+ if (newicache == NULL)
errx(1, "malloc");
- }
icache = newicache;
icache[nicache].ino = ino;
if (sblock->fs_magic == FS_UFS1_MAGIC)
@@ -321,13 +317,9 @@ addinode(ino_t ino)
{
ino_t *newilist;
- newilist = realloc(ilist, sizeof(ino_t) * (ninodes + 1));
- if (newilist == NULL) {
- if (ilist)
- free(ilist);
- ilist = NULL;
+ newilist = reallocarray(ilist, ninodes + 1, sizeof(ino_t));
+ if (newilist == NULL)
errx(4, "not enough memory to allocate tables");
- }
ilist = newilist;
ilist[ninodes] = ino;
ninodes++;