X-Git-Url: https://git.distorted.org.uk/~mdw/disorder/blobdiff_plain/d76bbdea349bf3856172ce9599e657d566e91162..c645bbf04f3a2d814d029a3e6010b5622d0e9224:/lib/mem.c diff --git a/lib/mem.c b/lib/mem.c index 89570ab..22b7228 100644 --- a/lib/mem.c +++ b/lib/mem.c @@ -72,7 +72,11 @@ void mem_init(void) { do_free = free; } else { GC_init(); +#ifdef HAVE_GC_GET_ALL_INTERIOR_POINTERS + assert(GC_get_all_interior_pointers()); +#else assert(GC_all_interior_pointers); +#endif } #endif } @@ -88,7 +92,7 @@ void *xmalloc(size_t n) { void *ptr; if(!(ptr = do_malloc(n)) && n) - fatal(errno, "error allocating memory"); + disorder_fatal(errno, "error allocating memory"); return ptr; } @@ -102,7 +106,7 @@ void *xmalloc(size_t n) { */ void *xrealloc(void *ptr, size_t n) { if(!(ptr = do_realloc(ptr, n)) && n) - fatal(errno, "error allocating memory"); + disorder_fatal(errno, "error allocating memory"); return ptr; } @@ -116,7 +120,7 @@ void *xrealloc(void *ptr, size_t n) { */ void *xcalloc(size_t count, size_t size) { if(count > SIZE_MAX / size) - fatal(0, "excessively large calloc"); + disorder_fatal(0, "excessively large calloc"); return xmalloc(count * size); } @@ -132,7 +136,7 @@ void *xmalloc_noptr(size_t n) { void *ptr; if(!(ptr = do_malloc_atomic(n)) && n) - fatal(errno, "error allocating memory"); + disorder_fatal(errno, "error allocating memory"); return ptr; } @@ -146,7 +150,7 @@ void *xmalloc_noptr(size_t n) { */ void *xcalloc_noptr(size_t count, size_t size) { if(count > SIZE_MAX / size) - fatal(0, "excessively large calloc"); + disorder_fatal(0, "excessively large calloc"); return xmalloc_noptr(count * size); } @@ -163,7 +167,7 @@ void *xrealloc_noptr(void *ptr, size_t n) { if(ptr == 0) return xmalloc_noptr(n); if(!(ptr = do_realloc(ptr, n)) && n) - fatal(errno, "error allocating memory"); + disorder_fatal(errno, "error allocating memory"); return ptr; } @@ -177,7 +181,7 @@ char *xstrdup(const char *s) { char *t; if(!(t = do_malloc_atomic(strlen(s) + 1))) - fatal(errno, "error allocating memory"); + disorder_fatal(errno, "error allocating memory"); return strcpy(t, s); } @@ -193,7 +197,7 @@ char *xstrndup(const char *s, size_t n) { char *t; if(!(t = do_malloc_atomic(n + 1))) - fatal(errno, "error allocating memory"); + disorder_fatal(errno, "error allocating memory"); memcpy(t, s, n); t[n] = 0; return t;