Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin realloc pedant
details: https://anonhg.NetBSD.org/src/rev/b09e5fa67a15
branches: trunk
changeset: 552114:b09e5fa67a15
user: itojun <itojun%NetBSD.org@localhost>
date: Fri Sep 19 07:08:50 2003 +0000
description:
realloc pedant
diffstat:
usr.bin/systat/vmstat.c | 10 ++++++----
usr.bin/vmstat/vmstat.c | 11 ++++++-----
2 files changed, 12 insertions(+), 9 deletions(-)
diffs (82 lines):
diff -r 80dfda1d19e8 -r b09e5fa67a15 usr.bin/systat/vmstat.c
--- a/usr.bin/systat/vmstat.c Fri Sep 19 06:22:03 2003 +0000
+++ b/usr.bin/systat/vmstat.c Fri Sep 19 07:08:50 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.54 2003/08/30 12:57:03 dsl Exp $ */
+/* $NetBSD: vmstat.c,v 1.55 2003/09/19 07:08:50 itojun Exp $ */
/*-
* Copyright (c) 1983, 1989, 1992, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 1/12/94";
#endif
-__RCSID("$NetBSD: vmstat.c,v 1.54 2003/08/30 12:57:03 dsl Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.55 2003/09/19 07:08:50 itojun Exp $");
#endif /* not lint */
/*
@@ -169,6 +169,7 @@
struct evcntlist allevents;
struct evcnt evcnt, *evptr;
intr_evcnt_t *ie;
+ intr_evcnt_t *n;
if (!NREAD(X_ALLEVENTS, &allevents, sizeof allevents))
return;
@@ -178,11 +179,12 @@
return;
if (evcnt.ev_type != EVCNT_TYPE_INTR)
continue;
- ie_head = realloc(ie_head, sizeof *ie * (nevcnt + 1));
- if (ie_head == NULL) {
+ n = realloc(ie_head, sizeof *ie * (nevcnt + 1));
+ if (n == NULL) {
error("realloc failed");
die(0);
}
+ ie_head = n;
ie = ie_head + nevcnt;
ie->ie_group = malloc(evcnt.ev_grouplen + 1);
ie->ie_name = malloc(evcnt.ev_namelen + 1);
diff -r 80dfda1d19e8 -r b09e5fa67a15 usr.bin/vmstat/vmstat.c
--- a/usr.bin/vmstat/vmstat.c Fri Sep 19 06:22:03 2003 +0000
+++ b/usr.bin/vmstat/vmstat.c Fri Sep 19 07:08:50 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.117 2003/08/07 11:17:11 agc Exp $ */
+/* $NetBSD: vmstat.c,v 1.118 2003/09/19 07:10:30 itojun Exp $ */
/*-
* Copyright (c) 1998, 2000, 2001 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
#if 0
static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 3/1/95";
#else
-__RCSID("$NetBSD: vmstat.c,v 1.117 2003/08/07 11:17:11 agc Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.118 2003/09/19 07:10:30 itojun Exp $");
#endif
#endif /* not lint */
@@ -1210,7 +1210,7 @@
LIST_HEAD(, generic) *hashtbl_list;
TAILQ_HEAD(, generic) *hashtbl_tailq;
struct kernel_hash *curhash;
- void *hashaddr, *hashbuf, *nextaddr;
+ void *hashaddr, *hashbuf, *nhashbuf, *nextaddr;
size_t elemsize, hashbufsize, thissize;
u_long hashsize;
int i, used, items, chain, maxchain;
@@ -1276,10 +1276,11 @@
(unsigned long long)elemsize);
thissize = hashsize * elemsize;
if (thissize > hashbufsize) {
- hashbufsize = thissize;
- if ((hashbuf = realloc(hashbuf, hashbufsize)) == NULL)
+ if ((nhashbuf = realloc(hashbuf, thissize)) == NULL)
errx(1, "malloc hashbuf %llu",
(unsigned long long)hashbufsize);
+ hashbuf = nhashbuf;
+ hashbufsize = thissize;
}
deref_kptr(hashaddr, hashbuf, thissize,
hashnl[curhash->hashtbl].n_name);
Home |
Main Index |
Thread Index |
Old Index