From bb8fd0a2ac5c84f17763807f33e1d1f8d492f51d Mon Sep 17 00:00:00 2001 From: glass Date: Thu, 12 May 1994 14:15:03 +0000 Subject: [PATCH] slightly more optimal fix from torek himself --- sys/kern/subr_autoconf.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/kern/subr_autoconf.c b/sys/kern/subr_autoconf.c index 091a57f6045f..5ced89c0a8ff 100644 --- a/sys/kern/subr_autoconf.c +++ b/sys/kern/subr_autoconf.c @@ -15,7 +15,7 @@ * * %W% (Berkeley) %G% * - * from: $Header: /cvsroot/src/sys/kern/subr_autoconf.c,v 1.5 1994/05/12 05:21:45 glass Exp $ (LBL) + * from: $Header: /cvsroot/src/sys/kern/subr_autoconf.c,v 1.6 1994/05/12 14:15:03 glass Exp $ (LBL) */ #include @@ -266,19 +266,18 @@ config_attach(parent, cf, aux, print) void **nsp; if (old == 0) { - newbytes = max(MINALLOCSIZE, - sizeof(void *) * (dev->dv_unit + 1)); + new = max(MINALLOCSIZE / sizeof(void *), + dev->dv_unit + 1); + newbytes = new * sizeof(void *); nsp = malloc(newbytes, M_DEVBUF, M_NOWAIT); if (!nsp) panic("config_attach: expanding dev array"); bzero(nsp, newbytes); - cd->cd_ndevs = newbytes / sizeof(void *); } else { new = cd->cd_ndevs; do { new *= 2; } while (new <= dev->dv_unit); - cd->cd_ndevs = new; oldbytes = old * sizeof(void *); newbytes = new * sizeof(void *); nsp = malloc(newbytes, M_DEVBUF, M_NOWAIT); @@ -288,6 +287,7 @@ config_attach(parent, cf, aux, print) bzero(&nsp[old], newbytes - oldbytes); free(cd->cd_devs, M_DEVBUF); } + cd->cd_ndevs = new; cd->cd_devs = nsp; } if (cd->cd_devs[dev->dv_unit])