mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 20:39:01 +00:00
37 lines
947 B
C#
37 lines
947 B
C#
using System;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Cosmos.Core.Memory.Old
|
|
{
|
|
// The DataLookupTable (DLT) basically is a double linked list.
|
|
[StructLayout(LayoutKind.Explicit)]
|
|
internal unsafe struct DataLookupTable
|
|
{
|
|
public const int EntriesPerTable = 170;
|
|
|
|
[FieldOffset(0)]
|
|
public DataLookupTable* Previous;
|
|
[FieldOffset(4)]
|
|
public DataLookupTable* Next;
|
|
|
|
[FieldOffset(8)]
|
|
public DataLookupEntry FirstEntry;
|
|
|
|
public unsafe DataLookupEntry* GetEntry(uint index)
|
|
{
|
|
fixed (DataLookupEntry* xFirstEntryPtr = &FirstEntry)
|
|
{
|
|
if (index == 0)
|
|
{
|
|
return xFirstEntryPtr;
|
|
}
|
|
else
|
|
{
|
|
return &xFirstEntryPtr[index];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|