mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-03-14 08:10:18 +00:00
Explicitly check for invalid memory ranges on the MultiRangeList
This commit is contained in:
parent
31df134769
commit
921776714b
1 changed files with 29 additions and 0 deletions
|
@ -29,6 +29,12 @@ namespace Ryujinx.Memory.Range
|
|||
for (int i = 0; i < range.Count; i++)
|
||||
{
|
||||
var subrange = range.GetSubRange(i);
|
||||
|
||||
if (IsInvalid(ref subrange))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
_items.Add(subrange.Address, subrange.EndAddress, item);
|
||||
}
|
||||
|
||||
|
@ -49,6 +55,12 @@ namespace Ryujinx.Memory.Range
|
|||
for (int i = 0; i < range.Count; i++)
|
||||
{
|
||||
var subrange = range.GetSubRange(i);
|
||||
|
||||
if (IsInvalid(ref subrange))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
removed += _items.Remove(subrange.Address, item);
|
||||
}
|
||||
|
||||
|
@ -86,6 +98,12 @@ namespace Ryujinx.Memory.Range
|
|||
for (int i = 0; i < range.Count; i++)
|
||||
{
|
||||
var subrange = range.GetSubRange(i);
|
||||
|
||||
if (IsInvalid(ref subrange))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
overlapCount = _items.Get(subrange.Address, subrange.EndAddress, ref output, overlapCount);
|
||||
}
|
||||
|
||||
|
@ -124,6 +142,17 @@ namespace Ryujinx.Memory.Range
|
|||
return overlapCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a given sub-range of memory is invalid.
|
||||
/// Those are used to represent unmapped memory regions (holes in the region mapping).
|
||||
/// </summary>
|
||||
/// <param name="subRange">Memory range to checl</param>
|
||||
/// <returns>True if the memory range is considered invalid, false otherwise</returns>
|
||||
private static bool IsInvalid(ref MemoryRange subRange)
|
||||
{
|
||||
return subRange.Address == ulong.MaxValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all items on the list starting at the specified memory address.
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in a new issue