blob: 690b574199af4313deb6d1c95689f309e6d5661c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
/** \file xmalloc.h -- Declarations for the fail-on-OOM string functions */
#ifndef XMALLOC_H
#define XMALLOC_H
#include "config.h"
/* xmalloc.c */
#if defined(HAVE_VOIDPOINTER)
#define XMALLOCTYPE void
#else
#define XMALLOCTYPE char
#endif
/** Allocate \a n characters of memory, abort program on failure. */
XMALLOCTYPE *xmalloc(size_t n);
/** Reallocate \a n characters of memory, abort program on failure. */
XMALLOCTYPE *xrealloc(/*@null@*/ XMALLOCTYPE *, 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; }
/** Duplicate string \a src to a newly malloc()d memory region and return its
* pointer, abort program on failure. */
char *xstrdup(const char *src);
#endif
|