initial commit
[meshfrac] / src / util.h
1 #ifndef UTIL_H_
2 #define UTIL_H_
3
4 #include <stdio.h>
5 #include <stdlib.h>
6
7 #if defined(__WATCOMC__) || defined(_WIN32)
8 #include <malloc.h>
9 #else
10 #if !defined(__FreeBSD__) && !defined(__OpenBSD__)
11 #include <alloca.h>
12 #endif
13 #endif
14
15 #ifdef _MSC_VER
16 #define strcasecmp(s, k) stricmp(s, k)
17 #endif
18
19 #define malloc_nf(sz)   malloc_nf_impl(sz, __FILE__, __LINE__)
20 void *malloc_nf_impl(size_t sz, const char *file, int line);
21 #define calloc_nf(num, sz)      calloc_nf_impl(num, sz, __FILE__, __LINE__)
22 void *calloc_nf_impl(size_t num, size_t sz, const char *file, int line);
23 #define realloc_nf(p, sz)       realloc_nf_impl(p, sz, __FILE__, __LINE__)
24 void *realloc_nf_impl(void *p, size_t sz, const char *file, int line);
25 #define strdup_nf(s)    strdup_nf_impl(s, __FILE__, __LINE__)
26 char *strdup_nf_impl(const char *s, const char *file, int line);
27
28 int match_prefix(const char *str, const char *prefix);
29
30 #endif  /* UTIL_H_ */