-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDefs.h
68 lines (56 loc) · 1.34 KB
/
Defs.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 __DEFS_H__
#define __DEFS_H__
#include <stdio.h>
// NULL just in case ----------------------
#ifdef NULL
#undef NULL
#endif
#define NULL 0
// Deletes a buffer
#define RELEASE( x ) \
{ \
if( x != NULL ) \
{ \
delete x; \
x = NULL; \
} \
}
// Deletes an array of buffers
#define RELEASE_ARRAY( x ) \
{ \
if( x != NULL ) \
{ \
delete[] x; \
x = NULL; \
} \
\
}
#define IN_RANGE( value, min, max ) ( ((value) >= (min) && (value) <= (max)) ? 1 : 0 )
#define MIN( a, b ) ( ((a) < (b)) ? (a) : (b) )
#define MAX( a, b ) ( ((a) > (b)) ? (a) : (b) )
#define TO_BOOL( a ) ( (a != 0) ? true : false )
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned __int32 uint32;
typedef unsigned __int64 uint64;
template <class VALUE_TYPE> void SWAP(VALUE_TYPE& a, VALUE_TYPE& b)
{
VALUE_TYPE tmp = a;
a = b;
b = tmp;
}
// Standard string size
#define SHORT_STR 32
#define MID_STR 255
#define HUGE_STR 8192
// Joins a path and file
inline const char* const PATH(const char* folder, const char* file)
{
static char path[MID_STR];
sprintf_s(path, MID_STR, "%s/%s", folder, file);
return path;
}
// Performance macros
#define PERF_START(timer) timer.Start()
#define PERF_PEEK(timer) LOG("%s took %f ms", __FUNCTION__, timer.ReadMs())
#endif // __DEFS_H__