blob: c9fe5a046e2f159a0cd4f2830b6197b44e78977c (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#include <cstdio>
#include "SimpleMalloc.h"
#include <new>
extern "C" {
void* kcalloc(dword nmemb, dword size)
{
if (!nmemb || !size)
return nullptr;
return SimpleMalloc::allocateZeroed(nmemb * size);
}
void* kmalloc(dword size)
{
if (!size)
return nullptr;
return SimpleMalloc::allocate(size);
}
void kfree(void* ptr)
{
if (!ptr)
return;
SimpleMalloc::free((byte*)ptr);
}
void* krealloc(void* ptr, dword size)
{
if (!ptr)
return ptr;
return SimpleMalloc::reallocate((byte*)ptr, size);
}
}
void* operator new(std::size_t size)
{
return kmalloc(size);
}
void* operator new[](std::size_t size)
{
return kmalloc(size);
}
void operator delete(void* ptr)
{
return kfree(ptr);
}
void operator delete[](void* ptr)
{
return kfree(ptr);
}
void operator delete(void* ptr, size_t)
{
return kfree(ptr);
}
void operator delete[](void* ptr, size_t)
{
return kfree(ptr);
}
|