2013-05-01 14:52:55 +02:00
|
|
|
#ifndef __CAPWAP_DEBUG_HEADER__
|
|
|
|
#define __CAPWAP_DEBUG_HEADER__
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
2016-03-30 14:47:57 +02:00
|
|
|
#define ASSERT(expr) if (!(expr)) { log_printf(LOG_EMERG, "Assertion failed \'%s\': %s(%d)", #expr, __FILE__, __LINE__); capwap_exit(CAPWAP_ASSERT_CONDITION); }
|
2013-05-01 14:52:55 +02:00
|
|
|
|
|
|
|
/* Custom memory management */
|
|
|
|
#define capwap_alloc(x) capwap_alloc_debug(x, __FILE__, __LINE__)
|
|
|
|
void* capwap_alloc_debug(size_t size, const char* file, const int line);
|
|
|
|
#define capwap_free(x) capwap_free_debug(x, __FILE__, __LINE__)
|
|
|
|
void capwap_free_debug(void* p, const char* file, const int line);
|
|
|
|
|
|
|
|
int capwap_check_memory_leak(int verbose);
|
|
|
|
void capwap_dump_memory(void);
|
|
|
|
|
2014-02-08 18:03:38 +01:00
|
|
|
#ifdef USE_DEBUG_BACKTRACE
|
2013-11-10 22:07:55 +01:00
|
|
|
void capwap_backtrace_callstack(void);
|
2014-02-08 18:03:38 +01:00
|
|
|
#else
|
2014-09-10 21:58:23 +02:00
|
|
|
#define capwap_backtrace_callstack()
|
2014-02-08 18:03:38 +01:00
|
|
|
#endif
|
2013-11-10 22:07:55 +01:00
|
|
|
|
2013-05-01 14:52:55 +02:00
|
|
|
#else
|
|
|
|
|
|
|
|
#define DEBUG_BREAKPOINT()
|
|
|
|
|
|
|
|
#define ASSERT(expr)
|
|
|
|
|
|
|
|
/* Standard memory management */
|
2013-08-11 22:50:12 +02:00
|
|
|
#define capwap_alloc(l) ({ void* __x = malloc(l); if (!__x) capwap_outofmemory(); __x; })
|
2013-05-01 14:52:55 +02:00
|
|
|
#define capwap_free(x) free(x)
|
2016-03-14 10:58:24 +01:00
|
|
|
#define capwap_check_memory_leak(x) (0)
|
2014-09-10 21:58:23 +02:00
|
|
|
#define capwap_dump_memory()
|
|
|
|
#define capwap_backtrace_callstack()
|
2013-05-01 14:52:55 +02:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __CAPWAP_DEBUG_HEADER__ */
|
|
|
|
|