added scr_lvled, a bunch of libraries, and improved framework code
[raydungeon] / src / util.h
1 #ifndef UTIL_H_
2 #define UTIL_H_
3
4 #include <stdlib.h>
5 #include <stdint.h>
6
7 #if defined(__WATCOMC__) || defined(_WIN32) || defined(__DJGPP__)
8 #include <malloc.h>
9 #else
10 #include <alloca.h>
11 #endif
12
13 /* Non-failing versions of malloc/calloc/realloc. They never return 0, they call
14  * demo_abort on failure. Use the macros, don't call the *_impl functions.
15  */
16 #define malloc_nf(sz)   malloc_nf_impl(sz, __FILE__, __LINE__)
17 void *malloc_nf_impl(size_t sz, const char *file, int line);
18 #define calloc_nf(n, sz)        calloc_nf_impl(n, sz, __FILE__, __LINE__)
19 void *calloc_nf_impl(size_t num, size_t sz, const char *file, int line);
20 #define realloc_nf(p, sz)       realloc_nf_impl(p, sz, __FILE__, __LINE__)
21 void *realloc_nf_impl(void *p, size_t sz, const char *file, int line);
22 #define strdup_nf(s)    strdup_nf_impl(s, __FILE__, __LINE__)
23 char *strdup_nf_impl(const char *s, const char *file, int line);
24
25 #endif  /* UTIL_H_ */