Commit 008b030a authored by Matthias Andree's avatar Matthias Andree

Assume the malloc/realloc/free family uses void *.

Remove XMALLOCTYPE and support for char *. Hard-wire void.
parent ae33665e
......@@ -16,13 +16,12 @@
#include <stdlib.h>
#include "i18n.h"
XMALLOCTYPE *
xmalloc (size_t n)
void *xmalloc (size_t n)
{
XMALLOCTYPE *p;
void *p;
p = (XMALLOCTYPE *) malloc(n);
if (p == (XMALLOCTYPE *) 0)
p = (void *) malloc(n);
if (p == (void *) 0)
{
report(stderr, GT_("malloc failed\n"));
abort();
......@@ -30,13 +29,12 @@ xmalloc (size_t n)
return(p);
}
XMALLOCTYPE *
xrealloc (XMALLOCTYPE *p, size_t n)
void *xrealloc (void *p, size_t n)
{
if (p == 0)
return xmalloc (n);
p = (XMALLOCTYPE *) realloc(p, n);
if (p == (XMALLOCTYPE *) 0)
p = (void *) realloc(p, n);
if (p == (void *) 0)
{
report(stderr, GT_("realloc failed\n"));
abort();
......
......@@ -11,13 +11,12 @@ extern "C" {
#endif
/* xmalloc.c */
#define XMALLOCTYPE void
/** Allocate \a n characters of memory, abort program on failure. */
XMALLOCTYPE *xmalloc(size_t n);
void *xmalloc(size_t n);
/** Reallocate \a n characters of memory, abort program on failure. */
XMALLOCTYPE *xrealloc(/*@[email protected]*/ XMALLOCTYPE *, size_t n);
void *xrealloc(/*@[email protected]*/ 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; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment