acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
del.h
1// Created by camilo on 2022-10-27 22:25 <3ThomasBorregaardSorensen!!
2#pragma once
3
4
5#include "management.h"
6#include "memory.h"
7#include "acme/platform/acme.h"
8
9
10template<class t>
11inline void delptr(t *& p)
12{
13
14 if (p != nullptr)
15 {
16
17 delete p;
18
19 p = nullptr;
20
21 }
22
23}
24
25
26template<typename T>
27inline ::i32 type_is_null(const T * p)
28{
29
30 return (((uptr)(void *)p) < maximum(4096, sizeof(T)));
31
32}
33
34
35//#include "acme/prototype/string/_uhash.h"
36
37
38//class allocer;
39
40
41namespace acme
42{
43
44 template<typename T>
45 inline void del(T *& p)
46 {
47
48 try
49 {
50
51 if (!is_null(p))
52 {
53
54 T * pdel = p;
55
56 p = nullptr;
57
58 delete pdel;
59
60 }
61
62 }
63 catch (...)
64 {
65
66 }
67
68 }
69
70
71 template<typename T>
72 inline void delobj(T *& p);
73
74
75 template<typename T>
76 inline void adel(T *& p)
77 {
78
79
80 try
81 {
82
83 if (p != nullptr)
84 {
85
86 delete[] p;
87
88 p = nullptr;
89
90 }
91
92 }
93 catch (...)
94 {
95
96 }
97
98 }
99
100
101 template<typename T>
102 inline void free(T *& p)
103 {
104
105 //Thank you Mummi!!
106
107
108 try
109 {
110
111 if (p != nullptr)
112 {
113
114 void * pdel = (void *)p;
115
116 p = nullptr;
117
118 ::free(pdel);
119
120 }
121
122 }
123 catch (...)
124 {
125
126 }
127
128 }
129
130
131 template<typename T>
132 inline void memory_free(T *& p)
133 {
134
135 //Thank you Mummi!!
136
137 try
138 {
139
140 if (p != nullptr)
141 {
142
143 void * pdel = (void *)p;
144
145 p = nullptr;
146
147 ::acme::get()->m_pheapmanagement->memory(::heap::e_memory_main)->free(pdel);
148
149 }
150
151 }
152 catch (...)
153 {
154
155 }
156
157 }
158
159
160 template<typename T>
161 inline T * reset(T *& p, T * pNew)
162 {
163
164 ::acme::del(p);
165
166 return p = pNew;
167
168 }
169
170
171 //template<typename T>
172 //inline T * reset(T *& p)
173 //{
174
175 // ::acme::del(p);
176
177 // return p = allocateø T();
178
179 //}
180
181
182} // namespace acme
183
184
185
186
include "aura/graphics/image/context.h"
Definition aaaa__defer.h:32