mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #13249 from shenweip/mem_alloc
Correct the alignment size when allocating memory at a position
This commit is contained in:
commit
c2255fd10a
1 changed files with 2 additions and 2 deletions
|
@ -163,13 +163,13 @@ u32 BlockAllocator::AllocAt(u32 position, u32 size, const char *tag)
|
||||||
alignedPosition &= ~(grain_ - 1);
|
alignedPosition &= ~(grain_ - 1);
|
||||||
|
|
||||||
// Since the position was decreased, size must increase.
|
// Since the position was decreased, size must increase.
|
||||||
alignedSize += alignedPosition - position;
|
alignedSize += position - alignedPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Upalign size to grain.
|
// Upalign size to grain.
|
||||||
alignedSize = (alignedSize + grain_ - 1) & ~(grain_ - 1);
|
alignedSize = (alignedSize + grain_ - 1) & ~(grain_ - 1);
|
||||||
// Tell the caller the allocated size from their requested starting position.
|
// Tell the caller the allocated size from their requested starting position.
|
||||||
size = alignedSize - (alignedPosition - position);
|
size = alignedSize - (position - alignedPosition);
|
||||||
|
|
||||||
Block *bp = GetBlockFromAddress(alignedPosition);
|
Block *bp = GetBlockFromAddress(alignedPosition);
|
||||||
if (bp != NULL)
|
if (bp != NULL)
|
||||||
|
|
Loading…
Add table
Reference in a new issue