summaryrefslogtreecommitdiff
path: root/include/JSystem/JGadget/allocator.h
blob: 998668cf47974a0a7234ebd36359f5db1d54fb0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef _JSYSTEM_JGADGET_ALLOCATOR_H
#define _JSYSTEM_JGADGET_ALLOCATOR_H

#include "dolphin/types.h"

namespace JGadget {
template <typename T>
struct TAllocator {
    T* allocate(u32 count, const void *param_2) {
        return AllocateRaw(count * sizeof(T));
    }

    T* AllocateRaw(u32 size) {
        return (T*)operator new(size);
    }

    void deallocate(T* mem, u32 size) {
        DeallocateRaw(mem);
    }

    void DeallocateRaw(void* mem) {
        delete (T*)mem;
    }

    void destroy(T* p) {
        // JUT_ASSERT(68, p!=0);
    }

    /* 0x00 */ u8 mAllocator;
};

typedef TAllocator<void*> TVoidAllocator;
}; // namespace JGadget

#endif