mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-07 06:43:00 +03:00
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.h>. (assert): Do not define. [!defined NDEBUG] (__assert_fail): Define to __malloc_assert.
This commit is contained in:
@@ -23,6 +23,9 @@
|
|||||||
|| to respect codestyle.
|
|| to respect codestyle.
|
||||||
* libio/tst-memstream3.c (_FWRITE): Rename to FWRITE_FUNC.
|
* libio/tst-memstream3.c (_FWRITE): Rename to FWRITE_FUNC.
|
||||||
(do_test_bz20181): Rename accordingly.
|
(do_test_bz20181): Rename accordingly.
|
||||||
|
* malloc/malloc.c: Include <assert.h>.
|
||||||
|
(assert): Do not define.
|
||||||
|
[!defined NDEBUG] (__assert_fail): Define to __malloc_assert.
|
||||||
|
|
||||||
2018-01-29 Darius Rad <darius@bluespec.com>
|
2018-01-29 Darius Rad <darius@bluespec.com>
|
||||||
|
|
||||||
|
@@ -223,6 +223,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h> /* needed for malloc_stats */
|
#include <stdio.h> /* needed for malloc_stats */
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#include <shlib-compat.h>
|
#include <shlib-compat.h>
|
||||||
|
|
||||||
@@ -278,13 +279,9 @@
|
|||||||
#define MALLOC_DEBUG 0
|
#define MALLOC_DEBUG 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NDEBUG
|
#ifndef NDEBUG
|
||||||
# define assert(expr) ((void) 0)
|
# define __assert_fail(assertion, file, line, function) \
|
||||||
#else
|
__malloc_assert(assertion, file, line, function)
|
||||||
# define assert(expr) \
|
|
||||||
((expr) \
|
|
||||||
? ((void) 0) \
|
|
||||||
: __malloc_assert (#expr, __FILE__, __LINE__, __func__))
|
|
||||||
|
|
||||||
extern const char *__progname;
|
extern const char *__progname;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user