Fix alignment to be based on starting address

Related-To: LOCI-2342
Signed-off-by: Young Jin Yoon <young.jin.yoon@intel.com>
This commit is contained in:
Young Jin Yoon
2021-06-15 00:19:35 +00:00
committed by Compute-Runtime-Automation
parent a481c28e55
commit a1036ecc75
2 changed files with 28 additions and 1 deletions

View File

@@ -76,7 +76,8 @@ class HeapAllocator {
pLeftBound += sizeToAllocate;
}
} else {
const uint64_t misalignment = pRightBound - alignDown(pRightBound, alignment);
const uint64_t pStart = pRightBound - sizeToAllocate;
const uint64_t misalignment = pStart - alignDown(pStart, alignment);
if (pLeftBound + sizeToAllocate + misalignment <= pRightBound) {
if (misalignment) {
pRightBound -= misalignment;