ref: a6fd3cc8e3db0a5c813ccbdc76f9d2259ef37941
parent: e289fd8ccdfb081f16f02a025e53421aab7f90b7
author: cinap_lenrek <[email protected]>
date: Sun Feb 2 00:47:13 EST 2014
mallocalign: make sure alignptr offset is modulo align when -offset > align
--- a/sys/src/libc/port/pool.c
+++ b/sys/src/libc/port/pool.c
@@ -1042,11 +1042,12 @@
c = v;
if(align){
- off = (uintptr)c%align;
+ off = ((ulong)(uintptr)c) % align;
if(off != offset){
- c += offset - off;
- if(off > offset)
- c += align;
+ offset -= off;
+ if(offset < 0)
+ offset += align;
+ c += offset;
}
}
return c;
@@ -1080,8 +1081,7 @@
if(align){
if(offset < 0)
offset = align - ((-offset)%align);
- else
- offset %= align;
+ offset %= align;
}
asize = dsize+align;
v = poolallocl(p, asize);