And another improved version, we might want assert(false) before exit in
debug build:
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#define ALLOCATION_ERROR_EXIT_CODE -10
#define MAKESTR(x) #x
#define STRINGIFY(x) MAKESTR(x)
#ifdef WIN32
#define ALLOCATION_CHECK(PTR) if(!(PTR)) \
{ \
fputs("Out of memory error in file: "__FILE__ ", function:
"__FUNCTION__", line: "STRINGIFY(__LINE__)"\n", stderr); \
assert(false); \
exit(ALLOCATION_ERROR_EXIT_CODE); \
}
#else
#define ALLOCATION_CHECK(PTR) if(!(PTR)) \
{ \
fputs("Out of memory error\n", stderr); \
assert(false);
exit(ALLOCATION_ERROR_EXIT_CODE); \
}
#endif
_______________________________________________
sipxtapi-dev mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipxtapi-dev/