Implicit out of memory check in Release Mode
This commit is contained in:
parent
7ddb32d217
commit
badad6e71d
src/common
@ -99,8 +99,10 @@ int capwap_is_timeout(struct timeout_control* timeout, unsigned long index);
|
||||
void capwap_daemon(void);
|
||||
|
||||
/* */
|
||||
#define capwap_outofmemory() capwap_logging_fatal("Out of memory %s(%d)", __FILE__, __LINE__); \
|
||||
capwap_exit(CAPWAP_OUT_OF_MEMORY);
|
||||
#define capwap_outofmemory() do { \
|
||||
capwap_logging_fatal("Out of memory %s(%d)", __FILE__, __LINE__); \
|
||||
capwap_exit(CAPWAP_OUT_OF_MEMORY); \
|
||||
} while(0)
|
||||
|
||||
/* Helper buffer copy */
|
||||
char* capwap_duplicate_string(const char* source);
|
||||
|
@ -37,15 +37,15 @@ void* capwap_alloc_debug(size_t size, const char* file, const int line) {
|
||||
if (size <= 0) {
|
||||
capwap_logging_debug("%s(%d): Invalid memory size %d", file, line, size);
|
||||
DEBUG_BREAKPOINT();
|
||||
return NULL;
|
||||
capwap_exit(CAPWAP_ASSERT_CONDITION);
|
||||
}
|
||||
|
||||
/* Alloc block with memory block and canary */
|
||||
block = (struct capwap_memory_block*)malloc(sizeof(struct capwap_memory_block) + size + 4);
|
||||
if (!block) {
|
||||
capwap_logging_debug("Out of memory %s(%d)", __FILE__, __LINE__);
|
||||
capwap_logging_debug("Out of memory %s(%d)", file, line);
|
||||
DEBUG_BREAKPOINT();
|
||||
return NULL;
|
||||
capwap_exit(CAPWAP_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
/* Info memory block */
|
||||
|
@ -26,7 +26,7 @@ void capwap_dump_memory(void);
|
||||
#define ASSERT(expr)
|
||||
|
||||
/* Standard memory management */
|
||||
#define capwap_alloc(x) (void*)malloc(x)
|
||||
#define capwap_alloc(l) ({ void* __x = malloc(l); if (!__x) capwap_outofmemory(); __x; })
|
||||
#define capwap_free(x) free(x)
|
||||
#define capwap_check_memory_leak(x) (0)
|
||||
#define capwap_dump_memory() (0)
|
||||
|
Loading…
Reference in New Issue
Block a user