Beispiel #1
0
        public unsafe void RATMethods()
        {
            var xRAM = new byte[1024 * 1024];

            fixed(byte *xPtr = xRAM)
            {
                RAT.Debug = true;

                RAT.Init(xPtr, (uint)xRAM.Length);

                var largePage = RAT.AllocPages(RAT.PageType.HeapLarge, 3);

                Assert.AreEqual(RAT.PageType.HeapLarge, RAT.GetPageType(largePage));
                Assert.AreEqual(RAT.GetFirstRATIndex(largePage), RAT.GetFirstRATIndex((byte *)largePage + 20));
                Assert.AreEqual(RAT.PageType.HeapLarge, RAT.GetPageType((byte *)largePage + RAT.PageSize));
            }
        }
Beispiel #2
0
        public unsafe void TestRATHeapMethods()
        {
            var xRAM = new byte[10 * RAT.PageSize]; // 10 Pages - 1 for RAT and 9 for values

            fixed(byte *xPtr = xRAM)
            {
                RAT.Debug = true;
                RAT.Init(xPtr, (uint)xRAM.Length);

                var ptr1 = Heap.Alloc(10);
                var ptr2 = Heap.Alloc(10);
                var ptr3 = Heap.Alloc(10);

                Assert.AreNotEqual((uint)ptr1, (uint)ptr2);
                Assert.AreNotEqual((uint)ptr1, (uint)ptr3);
                Assert.AreNotEqual((uint)ptr2, (uint)ptr3);
                Assert.AreEqual(RAT.GetFirstRATIndex(ptr1), RAT.GetFirstRATIndex(ptr2));
                Assert.AreEqual(RAT.GetFirstRATIndex(ptr1), RAT.GetFirstRATIndex(ptr3));
                Assert.AreEqual((uint)RAT.GetPagePtr(ptr1), (uint)RAT.GetPagePtr(ptr2));
                Assert.AreEqual((uint)RAT.GetPagePtr(ptr1), (uint)RAT.GetPagePtr(ptr3));
            }
        }