vere: print arg to c3_malloc() et. al. on failure

This commit is contained in:
Ted Blackman 2019-12-08 19:32:55 -05:00
parent baedc50567
commit 10e7c0945a

View File

@ -86,21 +86,27 @@
/* Asserting allocators.
*/
# define c3_free(s) free(s)
# define c3_malloc(s) ({ \
void* rut = malloc(s); \
if ( 0 == rut ) { \
c3_assert(!"memory lost"); \
} \
# define c3_malloc(s) ({ \
void* rut = malloc(s); \
if ( 0 == rut ) { \
fprintf(stderr, "c3_malloc(%" PRIu64 ") failed\r\n", \
(c3_d)s); \
c3_assert(!"memory lost"); \
} \
rut;})
# define c3_calloc(s) ({ \
void* rut = calloc(1,s); \
if ( 0 == rut ) { \
c3_assert(!"memory lost"); \
} \
# define c3_calloc(s) ({ \
void* rut = calloc(1,s); \
if ( 0 == rut ) { \
fprintf(stderr, "c3_calloc(%" PRIu64 ") failed\r\n", \
(c3_d)s); \
c3_assert(!"memory lost"); \
} \
rut;})
# define c3_realloc(a, b) ({ \
void* rut = realloc(a, b); \
if ( 0 == rut ) { \
c3_assert(!"memory lost"); \
} \
# define c3_realloc(a, b) ({ \
void* rut = realloc(a, b); \
if ( 0 == rut ) { \
fprintf(stderr, "c3_realloc(%" PRIu64 ") failed\r\n", \
(c3_d)b); \
c3_assert(!"memory lost"); \
} \
rut;})