Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src realloc pedant
details: https://anonhg.NetBSD.org/src/rev/f7f30074ce6a
branches: trunk
changeset: 552111:f7f30074ce6a
user: itojun <itojun%NetBSD.org@localhost>
date: Fri Sep 19 06:01:24 2003 +0000
description:
realloc pedant
diffstat:
libexec/rmail/rmail.c | 15 ++++++++-------
usr.sbin/route6d/route6d.c | 15 ++++++++-------
2 files changed, 16 insertions(+), 14 deletions(-)
diffs (97 lines):
diff -r cdd72a9e7db9 -r f7f30074ce6a libexec/rmail/rmail.c
--- a/libexec/rmail/rmail.c Fri Sep 19 05:52:48 2003 +0000
+++ b/libexec/rmail/rmail.c Fri Sep 19 06:01:24 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rmail.c,v 1.18 2003/08/07 09:46:47 agc Exp $ */
+/* $NetBSD: rmail.c,v 1.19 2003/09/19 06:01:24 itojun Exp $ */
/*
* Copyright (c) 1988, 1993
@@ -36,7 +36,7 @@
#if 0
static char sccsid[] = "@(#)rmail.c 8.3 (Berkeley) 5/15/95";
#else
-__RCSID("$NetBSD: rmail.c,v 1.18 2003/08/07 09:46:47 agc Exp $");
+__RCSID("$NetBSD: rmail.c,v 1.19 2003/09/19 06:01:24 itojun Exp $");
#endif
#endif /* not lint */
@@ -90,11 +90,11 @@
{
FILE *fp;
struct stat sb;
- size_t fplen, fptlen, len;
+ size_t fplen, fptlen, len, nfptlen;
off_t offset;
int ch, debug, i, pdes[2], pid, status;
char *addrp, *domain, *p, *t;
- char *from_path, *from_sys, *from_user;
+ char *from_path, *from_sys, *from_user, *n;
char *args[100], buf[2048], lbuf[2048];
addrp = NULL; /* XXX gcc */
@@ -196,10 +196,11 @@
err(EX_TEMPFAIL, NULL);
}
if (fplen + len + 2 > fptlen) {
- fptlen += MAX(fplen + len + 2, 256);
- if ((from_path =
- realloc(from_path, fptlen)) == NULL)
+ nfptlen += MAX(fplen + len + 2, 256);
+ if ((n = realloc(from_path, nfptlen)) == NULL)
err(EX_TEMPFAIL, NULL);
+ from_path = n;
+ fptlen = nfptlen;
}
memmove(from_path + fplen, p, len);
fplen += len;
diff -r cdd72a9e7db9 -r f7f30074ce6a usr.sbin/route6d/route6d.c
--- a/usr.sbin/route6d/route6d.c Fri Sep 19 05:52:48 2003 +0000
+++ b/usr.sbin/route6d/route6d.c Fri Sep 19 06:01:24 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: route6d.c,v 1.47 2003/08/22 08:24:26 itojun Exp $ */
+/* $NetBSD: route6d.c,v 1.48 2003/09/19 06:07:52 itojun Exp $ */
/* $KAME: route6d.c,v 1.94 2002/10/26 20:08:55 itojun Exp $ */
/*
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: route6d.c,v 1.47 2003/08/22 08:24:26 itojun Exp $");
+__RCSID("$NetBSD: route6d.c,v 1.48 2003/09/19 06:07:52 itojun Exp $");
#endif
#include <stdio.h>
@@ -3361,7 +3361,7 @@
void
setindex2ifc(int idx, struct ifc *ifcp)
{
- int n;
+ int n, nsize;
struct ifc **p;
if (!index2ifc) {
@@ -3375,17 +3375,18 @@
memset(index2ifc, 0, sizeof(*index2ifc) * nindex2ifc);
}
n = nindex2ifc;
- while (nindex2ifc <= idx)
- nindex2ifc *= 2;
- if (n != nindex2ifc) {
+ for (nsize = nindex2ifc; nsize <= idx; nsize *= 2)
+ ;
+ if (n != nsize) {
p = (struct ifc **)realloc(index2ifc,
- sizeof(*index2ifc) * nindex2ifc);
+ sizeof(*index2ifc) * nsize);
if (p == NULL) {
fatal("realloc");
/*NOTREACHED*/
}
memset(p + n, 0, sizeof(*index2ifc) * (nindex2ifc - n));
index2ifc = p;
+ nindex2ifc = nsize;
}
index2ifc[idx] = ifcp;
}
Home |
Main Index |
Thread Index |
Old Index