33 #ifndef __FREEWRL_INTERNAL_H__
34 #define __FREEWRL_INTERNAL_H__
37 extern const char *freewrl_get_version();
41 # define DEBUG_(_expr) _expr
43 # define DEBUG_(_expr)
47 #define DEBUG_MSG(...) DEBUG_(fprintf(stdout, __VA_ARGS__))
48 #define TRACE_MSG(...) DEBUG_(fprintf(stdout, __VA_ARGS__))
49 #define WARN_MSG(...) DEBUG_(fprintf(stdout, __VA_ARGS__))
51 #define ERROR_MSG(...) fprintf(stderr, __VA_ARGS__)
54 #define DEBUG_FW(...) DEBUG_(printf("FW: " __VA_ARGS__))
60 #define DEBUG_ARGS(...) DEBUG_(printf("TEXT: " __VA_ARGS__))
62 #define DEBUG_ARGS(...)
68 #if defined(FW_DEBUG) && defined(DEBUG_MALLOC)
70 # define MALLOC(t,_sz) ((t)freewrlMalloc(__LINE__,__FILE__,_sz,FALSE))
71 # define REALLOC(_a,_b) freewrlRealloc(__LINE__,__FILE__,_a,_b)
72 # define FREE(_ptr) freewrlFree(__LINE__,__FILE__,_ptr)
73 # define STRDUP(_a) freewrlStrdup(__LINE__,__FILE__,_a)
75 void *freewrlMalloc(
int line,
char *file,
size_t sz,
int zeroData);
76 void *freewrlRealloc(
int line,
char *file,
void *ptr,
size_t size);
77 void freewrlFree(
int line,
char *file,
void *a);
78 void *freewrlStrdup(
int line,
char *file,
char *str);
80 # define UNLINK(_fdd) do { \
81 TRACE_MSG("TRACE: unlink %s at %s:%d\n",_fdd,__FILE__,__LINE__); \
85 # define ASSERT(_ptr) do { if (!(_ptr)) { \
86 ERROR_MSG("ERROR: assert failed: %s (%s:%d)\n", #_ptr, __FILE__, __LINE__); } \
91 # define MALLOC(t,sz) ((t)malloc(sz))
92 # define REALLOC realloc
95 # define STRDUP _strdup
96 # define UNLINK _unlink
97 # define TEMPNAM _tempnam
99 # define STRDUP strdup
100 # define UNLINK unlink
101 # define TEMPNAM tempnam
103 # define ASSERT(_whatever)
109 #define FREE_IF_NZ(_ptr) if (_ptr) { \
113 DEBUG_MEM("free, pointer is already null at %s:%d\n", __FILE__, __LINE__); \