-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompat.h
33 lines (26 loc) · 1.11 KB
/
compat.h
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
// APK - Copyright (c) 2024 by Robin Southern. https://github.com/betajaen/apk
// Licensed under the MIT License; see LICENSE file.
#pragma once
#include "apk/pod.h"
#define _apk_to_str(x) #x
#define apk_to_str(x) _apk_to_str(x)
namespace apk {
void* _apk_allocate(APK_SIZE_TYPE size, const char* comment);
void _apk_deallocate(void* mem, const char* comment);
void* apk_allocate_chip(APK_SIZE_TYPE size);
void apk_deallocate_chip(void* mem);
template<typename T>
inline void _apk_delete(T*& mem, const char* comment) {
if (mem) {
mem->~T();
_apk_deallocate(mem, comment);
mem = NULL;
}
}
}
void* APK_ATTR_WEAK operator new(APK_SIZE_TYPE size, void* p);
void* APK_ATTR_WEAK operator new(APK_SIZE_TYPE size, const char* comment);
#define apk_new new(__FILE__ ":" apk_to_str(__LINE__))
#define apk_delete(MEM) ::apk::_apk_delete(MEM, __FILE__ ":" apk_to_str(__LINE__))
#define apk_allocate(SIZE) ::apk::_apk_allocate(SIZE, __FILE__ ":" apk_to_str(__LINE__))
#define apk_deallocate(MEM) ::apk::_apk_deallocate(MEM, __FILE__ ":" apk_to_str(__LINE__))