mallocalign: make sure alignptr offset is modulo align when -offset > align
This commit is contained in:
parent
e289fd8ccd
commit
a6fd3cc8e3
1 changed files with 6 additions and 6 deletions
|
@ -1042,11 +1042,12 @@ alignptr(void *v, ulong align, long offset)
|
|||
|
||||
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,7 +1081,6 @@ poolallocalignl(Pool *p, ulong dsize, ulong align, long offset, ulong span)
|
|||
if(align){
|
||||
if(offset < 0)
|
||||
offset = align - ((-offset)%align);
|
||||
else
|
||||
offset %= align;
|
||||
}
|
||||
asize = dsize+align;
|
||||
|
|
Loading…
Reference in a new issue