diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2018-10-20 19:52:54 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2018-10-20 19:52:54 +0200 |
commit | 37dcb25eee726a6e207963e737e12cc5a95ca398 (patch) | |
tree | 9f7f985bc3218da26f57baf60f8694a668cc9822 /sys/src/9/port/allocb.c | |
parent | c4ec69045e40277433a7fdc48c0ff4b19a11fa59 (diff) |
kernel: fix allocb for BLOCKALIGN*2 >= Hdrspc
Diffstat (limited to 'sys/src/9/port/allocb.c')
-rw-r--r-- | sys/src/9/port/allocb.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/sys/src/9/port/allocb.c b/sys/src/9/port/allocb.c index 24fc17d64..bb45551eb 100644 --- a/sys/src/9/port/allocb.c +++ b/sys/src/9/port/allocb.c @@ -19,7 +19,8 @@ _allocb(int size) uintptr addr; size += Tlrspc; - if((b = mallocz(sizeof(Block)+size+Hdrspc, 0)) == nil) + size = ROUND(size, BLOCKALIGN); + if((b = mallocz(sizeof(Block)+BLOCKALIGN+Hdrspc+size, 0)) == nil) return nil; b->next = nil; @@ -38,11 +39,8 @@ _allocb(int size) addr &= ~(BLOCKALIGN-1); b->lim = (uchar*)addr; - /* leave sluff at beginning for added headers */ - b->rp = b->lim - ROUND(size, BLOCKALIGN); - if(b->rp < b->base) - panic("_allocb"); - b->wp = b->rp; + /* leave room at beginning for added headers */ + b->wp = b->rp = b->lim - size; return b; } |