Example #1
0
    public void AllocationRoot_WithEmptyLeadingAllocations()
    {
        byte *  first;
        IntPtr *second;

        var allocator = new BatchAllocator(Allocator.TempJob);

        allocator.Allocate(0, &first);
        allocator.Allocate(1, &second);
        Assert.AreEqual(IntPtr.Zero, (IntPtr)allocator.AllocationRoot);
        allocator.Dispose();

        Assert.AreEqual((IntPtr)second, (IntPtr)allocator.AllocationRoot);
        Utility.FreeUnsafe(allocator.AllocationRoot, Allocator.TempJob);
    }
Example #2
0
    public void AllocationRoot_WithNoAllocations_IsNull()
    {
        var allocator = new BatchAllocator(Allocator.TempJob);

        allocator.Dispose();
        Assert.AreEqual(IntPtr.Zero, (IntPtr)allocator.AllocationRoot);

        byte *  first;
        IntPtr *second;

        allocator = new BatchAllocator(Allocator.TempJob);
        allocator.Allocate(0, &first);
        allocator.Allocate(0, &second);
        allocator.Dispose();
        Assert.AreEqual(IntPtr.Zero, (IntPtr)allocator.AllocationRoot);
    }