aboutsummaryrefslogtreecommitdiffstats
path: root/xmalloc.h
diff options
context:
space:
mode:
authorMatthias Andree <matthias.andree@gmx.de>2016-12-11 15:27:08 +0100
committerMatthias Andree <matthias.andree@gmx.de>2016-12-11 22:06:12 +0100
commitab4dd923d778048d5ba4a0bab7e730d0c157b322 (patch)
tree457480487346cdb8ffc5105d0791891e158893f9 /xmalloc.h
parente77d739e6a5ef96607f21229fb03530934b71d75 (diff)
downloadfetchmail-ab4dd923d778048d5ba4a0bab7e730d0c157b322.tar.gz
fetchmail-ab4dd923d778048d5ba4a0bab7e730d0c157b322.tar.bz2
fetchmail-ab4dd923d778048d5ba4a0bab7e730d0c157b322.zip
Fix portability to C90 and C++.
Diffstat (limited to 'xmalloc.h')
-rw-r--r--xmalloc.h13
1 files changed, 11 insertions, 2 deletions
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 <stdlib.h>
+
+#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