diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-09-25 04:23:27 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-09-25 04:23:27 +0000 |
commit | 7902a7453fbfa760c558203f856d7190d6111b21 (patch) | |
tree | 08c640bd204fe46e382cbb2cf2523cdd505e6ca7 /sbin | |
parent | 5f0fab5a39b7a6875afbadeff39f2b894853cf3b (diff) |
do not crank size first, do not do p = realloc(p, ...
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/fsck_ffs/inode.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c index 2d06db6772b..d64b96c7539 100644 --- a/sbin/fsck_ffs/inode.c +++ b/sbin/fsck_ffs/inode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inode.c,v 1.24 2003/08/25 23:28:15 tedu Exp $ */ +/* $OpenBSD: inode.c,v 1.25 2003/09/25 04:23:26 deraadt Exp $ */ /* $NetBSD: inode.c,v 1.23 1996/10/11 20:15:47 thorpej Exp $ */ /* @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)inode.c 8.5 (Berkeley) 2/8/95"; #else -static const char rcsid[] = "$OpenBSD: inode.c,v 1.24 2003/08/25 23:28:15 tedu Exp $"; +static const char rcsid[] = "$OpenBSD: inode.c,v 1.25 2003/09/25 04:23:26 deraadt Exp $"; #endif #endif /* not lint */ @@ -363,8 +363,9 @@ void cacheino(struct ufs1_dinode *dp, ino_t inumber) { struct inoinfo *inp; - struct inoinfo **inpp; + struct inoinfo **inpp, **newinpsort; unsigned int blks; + long newlistmax; blks = howmany(dp->di_size, sblock.fs_bsize); if (blks > NDADDR) @@ -386,11 +387,13 @@ cacheino(struct ufs1_dinode *dp, ino_t inumber) inp->i_numblks = blks * sizeof(daddr_t); memcpy(&inp->i_blks[0], &dp->di_db[0], (size_t)inp->i_numblks); if (inplast == listmax) { - listmax += 100; - inpsort = realloc(inpsort, - (unsigned)listmax * sizeof(struct inoinfo *)); - if (inpsort == NULL) + newlistmax = listmax + 100; + newinpsort = realloc(inpsort, + (unsigned)newlistmax * sizeof(struct inoinfo *)); + if (newinpsort == NULL) errexit("cannot increase directory list"); + inpsort = newinpsort; + listmax = newlistmax; } inpsort[inplast++] = inp; } |