From 406e7a0a47110adbf79326c8a0bda5ffac3e0f10 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 29 Jan 2018 22:49:45 +0100 Subject: malloc: Use assert.h's assert macro This avoids assert definition conflicts if some of the headers used by malloc.c happens to include assert.h. Malloc still needs a malloc-avoiding implementation, which we get by redirecting __assert_fail to malloc's __malloc_assert. * malloc/malloc.c: Include . (assert): Do not define. [!defined NDEBUG] (__assert_fail): Define to __malloc_assert. --- malloc/malloc.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'malloc') diff --git a/malloc/malloc.c b/malloc/malloc.c index 7889fb1961..f8e7250f70 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -223,6 +223,7 @@ #include #include /* needed for malloc_stats */ #include +#include #include @@ -278,13 +279,9 @@ #define MALLOC_DEBUG 0 #endif -#ifdef NDEBUG -# define assert(expr) ((void) 0) -#else -# define assert(expr) \ - ((expr) \ - ? ((void) 0) \ - : __malloc_assert (#expr, __FILE__, __LINE__, __func__)) +#ifndef NDEBUG +# define __assert_fail(assertion, file, line, function) \ + __malloc_assert(assertion, file, line, function) extern const char *__progname; -- cgit v1.2.3