public void DefaultCAllocatorTest()
        {
            DefaultCppAllocator allocator = DefaultCppAllocator.Instance;

            Assert.AreSame(allocator, Allocator.GetAllocatorByID(allocator.ID));
            Assert.IsTrue(Allocator.IsCached(allocator));

            int *p = allocator.Allocate <int>(4);

            for (int i = 0; i < 4; i++)
            {
                p[i] = i + 1;
            }

            Assert.AreEqual(1, p[0]);
            Assert.AreEqual(2, p[1]);
            Assert.AreEqual(3, p[2]);
            Assert.AreEqual(4, p[3]);

            p = allocator.Reallocate(p, 6);
            Assert.AreEqual(1, p[0]);
            Assert.AreEqual(2, p[1]);
            Assert.AreEqual(3, p[2]);
            Assert.AreEqual(4, p[3]);
            Assert.AreEqual(0, p[4]);
            Assert.AreEqual(0, p[5]);

            allocator.Free(p);
        }
Example #2
0
        public void Setup()
        {
            int AllocatorSize = Bytes * 2;
            var defaultAlloc  = Allocator.Default;

            if (defaultAlloc == null)
            {
                throw new Exception("Null default allocator");
            }

            heapAllocator      = DefaultHeapAllocator.Instance;
            localAllocator     = DefaultLocalAllocator.Instance;
            cAllocator         = DefaultCppAllocator.Instance;
            arenaAllocator     = new ArenaAllocator(AllocatorSize);
            stackAllocator     = new StackAllocator(AllocatorSize);
            fixedPoolAllocator = new FixedMemoryPoolAllocator(10, AllocatorSize);
            poolAllocator      = new MemoryPoolAllocator(AllocatorSize);
        }
Example #3
0
 public void Setup()
 {
     cppAllocator = DefaultCppAllocator.Instance;
 }