From ab4dd923d778048d5ba4a0bab7e730d0c157b322 Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Sun, 11 Dec 2016 15:27:08 +0100 Subject: Fix portability to C90 and C++. --- xmalloc.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'xmalloc.h') diff --git a/xmalloc.h b/xmalloc.h index 81835828..70ed0a0b 100644 --- a/xmalloc.h +++ b/xmalloc.h @@ -4,9 +4,14 @@ #define XMALLOC_H #include "config.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif /* xmalloc.c */ -#if defined(HAVE_VOIDPOINTER) +#if defined(HAVE_VOIDPOINTER) || defined(__cplusplus) #define XMALLOCTYPE void #else #define XMALLOCTYPE char @@ -16,7 +21,7 @@ XMALLOCTYPE *xmalloc(size_t n); /** Reallocate \a n characters of memory, abort program on failure. */ -XMALLOCTYPE *xrealloc(/*@null@*/ XMALLOCTYPE *, size_t n); +XMALLOCTYPE *xrealloc(/*@null@*/ void *, size_t n); /** Free memory at position \a p and set pointer \a p to NULL afterwards. */ #define xfree(p) { if (p) { free(p); } (p) = 0; } @@ -31,4 +36,8 @@ char *xstrdup(const char *src); * length including NUL byte or n + 1. */ char *xstrndup(const char *src, size_t n); +#ifdef __cplusplus +} +#endif + #endif -- cgit v1.2.3