From b14b4318bf069340cbedff3f3939b56fe514376c Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 9 Apr 1993 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1993-04-09 --- pc/bbmalloc.c | 15 +++++++++------ pc/devvga.c | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pc/bbmalloc.c b/pc/bbmalloc.c index f1087f1dc9325cf89b950fb25832d96bbf63e425..f216af964a4d112913363f2496a24f6b57326dfc 100644 --- a/pc/bbmalloc.c +++ b/pc/bbmalloc.c @@ -19,8 +19,8 @@ enum { }; static ulong *bbarena[narena]; -static ulong *bbcur[narena] = {&bbarena[0][0], &bbarena[1][0]}; -static ulong *bblast[narena] = {0, 0}; +static ulong *bbcur[narena]; +static ulong *bblast[narena]; #define INTENABLED(v) ((v)&(1<<9)) void * @@ -33,13 +33,13 @@ bbmalloc(int nbytes) nw = nbytes/sizeof(long); s = splhi(); a = INTENABLED(s) ? 0 : 1; - if(bbcur[a] + nw > &bbarena[a][nbbarena]) + if(bbcur[a] + nw > bbarena[a] + nbbarena) ans = bbarena[a]; else ans = bbcur[a]; bbcur[a] = ans + nw; - splx(s); bblast[a] = ans; + splx(s); return ans; } @@ -50,8 +50,11 @@ bbinit(void) if(bbarena[0]) return; - for(i = 0; i < narena; i++) - bbarena[i] = xalloc(nbbarena); + for(i = 0; i < narena; i++){ + bbarena[i] = xalloc(nbbarena * sizeof(long)); + bbcur[i] = bbarena[i]; + bblast[i] = 0; + } } diff --git a/pc/devvga.c b/pc/devvga.c index e38ebf8cf40b77bbc766057a33231482c0ae1e30..2eb005a2d66746f5ec51e12fdc7e2cebf8c6113e 100644 --- a/pc/devvga.c +++ b/pc/devvga.c @@ -293,7 +293,6 @@ vgawrite(Chan *c, void *buf, long n, ulong offset) || ldepth > 3 || ldepth < 0) error(Ebadarg); cursoroff(1); - bbinit(); setscreen(maxx, maxy, ldepth); cursoron(1); return n; @@ -562,6 +561,7 @@ setscreen(int maxx, int maxy, int ldepth) gscreen.ldepth = ldepth; break; } + bbinit(); cga = 0; /*