mirror of
https://github.com/thunderbrewhq/squall.git
synced 2026-02-03 16:39:08 +00:00
feat(memory): add STORM_ALLOC and STORM_NEW macros
This commit is contained in:
parent
595e431d92
commit
20457f7d4c
5 changed files with 16 additions and 8 deletions
|
|
@ -99,8 +99,7 @@ void SBigMul(BigData* a, BigData* b, BigData* c) {
|
|||
}
|
||||
|
||||
void SBigNew(BigData** num) {
|
||||
auto m = SMemAlloc(sizeof(BigData), __FILE__, __LINE__, 0x0);
|
||||
*num = new (m) BigData();
|
||||
*num = STORM_NEW(BigData);
|
||||
}
|
||||
|
||||
void SBigNot(BigData* a, BigData* b) {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,18 @@
|
|||
|
||||
#define SMEM_FLAG_ZEROMEMORY 0x8
|
||||
|
||||
#define STORM_ALLOC(bytes) \
|
||||
SMemAlloc(bytes, __FILE__, __LINE__, 0x0)
|
||||
|
||||
#define STORM_ALLOC_ZERO(bytes) \
|
||||
SMemAlloc(bytes, __FILE__, __LINE__, SMEM_FLAG_ZEROMEMORY)
|
||||
|
||||
#define STORM_NEW(t) \
|
||||
new(SMemAlloc(sizeof(t), __FILE__, __LINE__, 0x0)) t
|
||||
|
||||
#define STORM_NEW_ZERO(t) \
|
||||
new(SMemAlloc(sizeof(t), __FILE__, __LINE__, SMEM_FLAG_ZEROMEMORY)) t
|
||||
|
||||
void* SMemAlloc(size_t bytes, const char* filename, int32_t linenumber, uint32_t flags = 0);
|
||||
|
||||
void SMemCopy(void* dst, void* src, size_t bytes);
|
||||
|
|
|
|||
|
|
@ -40,8 +40,7 @@ void* SCreateThread(uint32_t (*threadProc)(void*), void* threadParam, void* a3,
|
|||
|
||||
uint32_t threadId = S_Thread::s_threadID++;
|
||||
|
||||
void* m = SMemAlloc(sizeof(SThreadParmBlock), __FILE__, __LINE__, 0x8);
|
||||
auto params = new (m) SThreadParmBlock();
|
||||
auto params = STORM_NEW_ZERO(SThreadParmBlock);
|
||||
params->threadProc = threadProc;
|
||||
params->threadParam = threadParam;
|
||||
params->threadID = threadId;
|
||||
|
|
|
|||
|
|
@ -40,8 +40,7 @@ void* SCreateThread(uint32_t (*threadProc)(void*), void* threadParam, void* a3,
|
|||
|
||||
uint32_t threadId = S_Thread::s_threadID++;
|
||||
|
||||
void* m = SMemAlloc(sizeof(SThreadParmBlock), __FILE__, __LINE__, 0x8);
|
||||
auto params = new (m) SThreadParmBlock();
|
||||
auto params = STORM_NEW_ZERO(SThreadParmBlock);
|
||||
params->threadProc = threadProc;
|
||||
params->threadParam = threadParam;
|
||||
params->threadID = threadId;
|
||||
|
|
|
|||
|
|
@ -38,8 +38,7 @@ void* SCreateThread(uint32_t (*threadProc)(void*), void* threadParam, void* a3,
|
|||
*/
|
||||
}
|
||||
|
||||
void* m = SMemAlloc(sizeof(SThreadParmBlock), __FILE__, __LINE__, 0x8);
|
||||
auto params = new (m) SThreadParmBlock();
|
||||
auto params = STORM_NEW(SThreadParmBlock);
|
||||
params->threadProc = threadProc;
|
||||
params->threadParam = threadParam;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue