Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/libexec realloc pedannt
details: https://anonhg.NetBSD.org/src/rev/cdd72a9e7db9
branches: trunk
changeset: 552110:cdd72a9e7db9
user: itojun <itojun%NetBSD.org@localhost>
date: Fri Sep 19 05:52:48 2003 +0000
description:
realloc pedannt
diffstat:
libexec/lfs_cleanerd/library.c | 14 ++++++++------
libexec/telnetd/sys_term.c | 11 +++++++----
2 files changed, 15 insertions(+), 10 deletions(-)
diffs (86 lines):
diff -r 6a04702dce93 -r cdd72a9e7db9 libexec/lfs_cleanerd/library.c
--- a/libexec/lfs_cleanerd/library.c Fri Sep 19 05:50:41 2003 +0000
+++ b/libexec/lfs_cleanerd/library.c Fri Sep 19 05:52:48 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: library.c,v 1.37 2003/08/07 09:46:43 agc Exp $ */
+/* $NetBSD: library.c,v 1.38 2003/09/19 05:52:48 itojun Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)library.c 8.3 (Berkeley) 5/24/95";
#else
-__RCSID("$NetBSD: library.c,v 1.37 2003/08/07 09:46:43 agc Exp $");
+__RCSID("$NetBSD: library.c,v 1.38 2003/09/19 05:52:48 itojun Exp $");
#endif
#endif /* not lint */
@@ -403,7 +403,7 @@
int
lfs_segmapv(FS_INFO *fsp, int seg, caddr_t seg_buf, BLOCK_INFO **blocks, int *bcount)
{
- BLOCK_INFO *bip, *_bip;
+ BLOCK_INFO *bip, *_bip, *nbip;
SEGSUM *sp;
SEGUSE *sup;
FINFO *fip;
@@ -475,10 +475,12 @@
#endif
if (*bcount + nblocks + sp->ss_ninos > nelem) {
+ nbip = realloc(bip, (*bcount + nblocks + sp->ss_ninos) *
+ sizeof(BLOCK_INFO));
+ if (!nbip)
+ goto err0;
+ bip = nbip;
nelem = *bcount + nblocks + sp->ss_ninos;
- bip = realloc(bip, nelem * sizeof(BLOCK_INFO));
- if (!bip)
- goto err0;
}
add_blocks(fsp, bip, bcount, sp, seg_buf, seg_addr, pseg_addr);
add_inodes(fsp, bip, bcount, sp, seg_buf, seg_addr);
diff -r 6a04702dce93 -r cdd72a9e7db9 libexec/telnetd/sys_term.c
--- a/libexec/telnetd/sys_term.c Fri Sep 19 05:50:41 2003 +0000
+++ b/libexec/telnetd/sys_term.c Fri Sep 19 05:52:48 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_term.c,v 1.39 2003/08/07 09:46:52 agc Exp $ */
+/* $NetBSD: sys_term.c,v 1.40 2003/09/19 05:54:46 itojun Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)sys_term.c 8.4+1 (Berkeley) 5/30/95";
#else
-__RCSID("$NetBSD: sys_term.c,v 1.39 2003/08/07 09:46:52 agc Exp $");
+__RCSID("$NetBSD: sys_term.c,v 1.40 2003/09/19 05:54:46 itojun Exp $");
#endif
#endif /* not lint */
@@ -700,6 +700,7 @@
register char *val;
{
register char **cpp;
+ char **nargv;
if (argv == NULL) {
/*
@@ -715,12 +716,14 @@
;
if (cpp == &argv[(long)argv[-1]]) {
--argv;
- *argv = (char *)((long)(*argv) + 10);
- argv = (char **)realloc(argv, sizeof(*argv) * ((long)(*argv) + 2));
+ nargv = (char **)realloc(argv,
+ sizeof(*argv) * ((long)(*argv) + 10 + 2));
if (argv == NULL) {
fatal(net, "not enough memory");
/*NOTREACHED*/
}
+ argv = nargv;
+ *argv = (char *)((long)(*argv) + 10);
argv++;
cpp = &argv[(long)argv[-1] - 10];
}
Home |
Main Index |
Thread Index |
Old Index