From a0b9f2fb512ba61a058ed1c10f330900df911bbb Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Thu, 26 Aug 2021 23:53:14 +0200 Subject: xmalloc.h: Add GCC malloc attribute to xmalloc(). --- xmalloc.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'xmalloc.h') diff --git a/xmalloc.h b/xmalloc.h index 70ed0a0b..fd84ebed 100644 --- a/xmalloc.h +++ b/xmalloc.h @@ -17,8 +17,12 @@ extern "C" { #define XMALLOCTYPE char #endif +#if !defined __GNUC__ || __GNUC__ < 2 +# define __attribute__(xyz) /* Ignore. */ +#endif + /** Allocate \a n characters of memory, abort program on failure. */ -XMALLOCTYPE *xmalloc(size_t n); +XMALLOCTYPE *xmalloc(size_t n) __attribute__((malloc)); /** Reallocate \a n characters of memory, abort program on failure. */ XMALLOCTYPE *xrealloc(/*@null@*/ void *, size_t n); -- cgit v1.2.3