Doxygen Samurai Engine 0.0.1
Doxygen Samurai Engine Documentation
Loading...
Searching...
No Matches
globalAllocator.cpp
Go to the documentation of this file.
1#include "globalAllocator.h"
2#include <malloc.h>
3#include <fstream>
4
5#include "CustomAllocator.h"
6
7
8void *DefaultAllocator(size_t size)
9{
10 return malloc(size);
11}
12void DefaultFree(void *ptr)
13{
14 free(ptr);
15}
16
17void *DisabeledAllocator(size_t size)
18{
19 return 0;
20}
21void DisabeledFree(void *ptr)
22{
23 (void)ptr;
24}
25
27void *CustomedAllocator(size_t size)
28{
29 return currentCustomAllocator->allocate(size);
30}
31void CustomFree(void *ptr)
32{
34}
35
36void* (*GlobalAllocateFunction)(size_t) = DefaultAllocator;
37void (*GlobalFree)(void *) = DefaultFree;
38
39namespace samurai
40{
41namespace memory
42{
48
54
61}
62}
63
64
65
66void *operator new (size_t count)
67{
68 return GlobalAllocateFunction(count);
69}
70
71void *operator new[](size_t count)
72{
73 return GlobalAllocateFunction(count);
74}
75
76void operator delete (void *ptr)
77{
78
79 GlobalFree(ptr);
80}
81
82void operator delete[](void *ptr)
83{
84 GlobalFree(ptr);
85}
void *(* GlobalAllocateFunction)(size_t)
void CustomFree(void *ptr)
void DefaultFree(void *ptr)
void(* GlobalFree)(void *)
void * DisabeledAllocator(size_t size)
samurai::memory::CustomAllocator * currentCustomAllocator
void * DefaultAllocator(size_t size)
void DisabeledFree(void *ptr)
void * CustomedAllocator(size_t size)
void setGlobalAllocator(samurai::memory::CustomAllocator *allocator)
void setGlobalAllocatorToStandard()