aboutsummaryrefslogtreecommitdiff
path: root/ARMeilleure/Common/Allocator.cs
blob: 247a8e8bc1ccf6dd96f9a55a8e12e5e45a587da9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;

namespace ARMeilleure.Common
{
    unsafe abstract class Allocator : IDisposable
    {
        public T* Allocate<T>(ulong count = 1) where T : unmanaged
        {
            return (T*)Allocate(count * (uint)sizeof(T));
        }

        public abstract void* Allocate(ulong size);

        public abstract void Free(void* block);

        protected virtual void Dispose(bool disposing) { }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }
    }
}