-
Notifications
You must be signed in to change notification settings - Fork 19
/
CommonTypes.h
68 lines (51 loc) · 1.71 KB
/
CommonTypes.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
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
67
68
#ifndef COMMON_TYPES_H
#define COMMON_TYPES_H
#include "PlatformDef.h"
#include <cstring>
#include <cstdint>
#include <cstdbool>
#if PLATFORM_WIN
//Enable this to check memory allocations.
//This is currently only available on Windows
#ifdef _CRTDBG_MAP_ALLOC
#include <cstdlib>
#include <CRTDBG.h>
#define xlMalloc(s) _malloc_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
#define xlCalloc(c, s) _calloc_dbg(c, s, _NORMAL_BLOCK, __FILE__, __LINE__)
#define xlRealloc(p, s) _realloc_dbg(p, s, _NORMAL_BLOCK, __FILE__, __LINE__)
#define xlExpand(p, s) _expand_dbg(p, s, _NORMAL_BLOCK, __FILE__, __LINE__)
#define xlFree(p) _free_dbg(p, _NORMAL_BLOCK)
#define xlMemSize(p) _msize_dbg(p, _NORMAL_BLOCK)
#define xlNew new(_NORMAL_BLOCK, __FILE__, __LINE__)
#define xlDelete delete
#else
#define xlMalloc malloc
#define xlCalloc calloc
#define xlRealloc realloc
#define xlExpand _expand
#define xlFree free
#define xlMemSize _msize
#define xlNew new
#define xlDelete delete
#endif
#else
#define stricmp strcasecmp
#define strnicmp strncasecmp
//memory
#define xlMalloc malloc
#define xlCalloc calloc
#define xlRealloc realloc
#define xlExpand _expand
#define xlFree free
#define xlMemSize _msize
#define xlNew new
#define xlDelete delete
#endif
typedef int32_t XL_BOOL;
#define XL_INVALID_TEXTURE 0xffffffff
typedef uint32_t TextureHandle;
//Make sure that the point is non-null before delete. Set to null.
#define SafeDeleteArr(p) if (p) { xlDelete [] (p); (p) = nullptr; }
//p must be non-null before deletion. Test and set to null.
#define SafeDeleteArr_Test(p) { assert(p); if (p) { xlDelete [] (p); (p) = nullptr; } }
#endif //COMMON_TYPES