summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2018-03-10 19:19:18 -0800
committerOri Bernstein <ori@eigenstate.org>2018-03-10 19:19:18 -0800
commitdcd6fad70720c2c8baa5e0096f2b14e45e9aa447 (patch)
tree229d7337d799e44486243e892ba57dabf55ddcf5
parentdbf04d054d0fc04385c766ced8e0f3b3edd120e8 (diff)
downloadmc-dcd6fad70720c2c8baa5e0096f2b14e45e9aa447.tar.gz
Don't overallocate.
We were allocating data that was a bit too big.
-rw-r--r--lib/std/alloc.myr5
-rw-r--r--lib/std/bytealloc.myr1
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/std/alloc.myr b/lib/std/alloc.myr
index bc26a1c..b6f3ee9 100644
--- a/lib/std/alloc.myr
+++ b/lib/std/alloc.myr
@@ -131,7 +131,8 @@ generic slgrow = {sl : @a[:]#, len
if (sl# : byte#) != Zsliceptr
cap = slcap((sl# : byte#))
;;
- if cap >= allocsz(len*sizeof(@a)) + align(sizeof(slheader), Align)
+ if cap >= len*sizeof(@a)
+ /* cast to pointer to work around bounds check */
sl# = (sl# : @a#)[:len]
-> sl#
;;
@@ -139,7 +140,7 @@ generic slgrow = {sl : @a[:]#, len
/* grow in factors of 1.5 */
nel = sl#.len
while nel < len
- nel = nel * 2 + 2
+ nel += (nel >> 2) + 1
;;
new = slalloc(nel)
diff --git a/lib/std/bytealloc.myr b/lib/std/bytealloc.myr
index 4d2c921..4061d85 100644
--- a/lib/std/bytealloc.myr
+++ b/lib/std/bytealloc.myr
@@ -125,7 +125,6 @@ const writealloctrace = {sl
const bytealloc = {sz
var bkt, p
- sz += 8
if sz <= Bktmax
bkt = &buckets[bktnum(sz)]
lock(memlck)