-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.h
37 lines (29 loc) · 900 Bytes
/
types.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
#ifndef __TYPES_H__
#define __TYPES_H__
//Generic class form Ron that I use in everything, some usefull functions.
#include "stdint.h"
#ifndef TRUE
typedef enum
{
FALSE,
TRUE
} BOOLEANB;
#else
typedef int BOOLEANB;
#endif
#ifndef MIN
#define MIN(a,b) (a < b ? a : b)
#endif
#ifndef MAX
#define MAX(a,b) (a > b ? a : b)
#endif
#define DIE(a) {fprintf(stderr, "Unrecoverable error in %s(%d): %s\n\n", __FILE__, __LINE__, a); /*abort();*/}
#define DIE_MEM() {DIE("Out of memory.");}
/* Make calls to malloc/realloc that die cleanly if the calls fail. */
void *safe_malloc(uint32_t size);
void *safe_realloc(void *ptr, uint32_t size);
/* Create a UNICODE string based on an ASCII one. Be sure to free the memory! */
char *unicode_alloc(const char *string);
/* Same as unicode_alloc(), except convert the string to uppercase first. */
char *unicode_alloc_upper(const char *string);
#endif