mirror of
https://github.com/urbit/shrub.git
synced 2024-11-28 13:54:20 +03:00
Merge branch 'malloc-print' (#2061)
* origin/malloc-print: vere: print arg to c3_malloc() et. al. on failure Signed-off-by: Jared Tobin <jared@tlon.io>
This commit is contained in:
commit
69c2f5517c
@ -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;})
|
||||
|
Loading…
Reference in New Issue
Block a user