aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Memory/Range/MultiRangeList.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Memory/Range/MultiRangeList.cs')
-rw-r--r--Ryujinx.Memory/Range/MultiRangeList.cs29
1 files changed, 29 insertions, 0 deletions
diff --git a/Ryujinx.Memory/Range/MultiRangeList.cs b/Ryujinx.Memory/Range/MultiRangeList.cs
index 38ca63b4..5131889f 100644
--- a/Ryujinx.Memory/Range/MultiRangeList.cs
+++ b/Ryujinx.Memory/Range/MultiRangeList.cs
@@ -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);
}
@@ -125,6 +143,17 @@ namespace Ryujinx.Memory.Range
}
/// <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>
/// <param name="baseAddress">Base address to find</param>