3 * File name: ir/adt/xmalloc.h
4 * Purpose: More comfortable allocations.
5 * Author: Markus Armbruster
7 * Created: 1999 by getting from fiasco
9 * Copyright: (c) 1995, 1996 Markus Armbruster
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
19 /* Declare alloca() */
22 /* @@@ on a true GNU system, this is defined by stdlib.h */
24 # define alloca(size) __builtin_alloca (size)
29 # if defined(_AIX) && !defined(C_ALLOCA)
30 /* if your version of AIX chokes on this, use gcc @@@ or alloca.o */
33 # ifndef alloca /* predefined by HP cc +Olibcalls */
40 /* xmalloc() & friends.
42 The macros set tmalloc_tag to __FILE__, the functions leave it
43 alone. Use the latter if you set it yourself. See tmalloc.c for
46 extern void *xmalloc (size_t);
47 extern void *xrealloc (void *, size_t);
48 extern char *xstrdup (const char *);
49 extern void xnomem (void);
50 extern void free (void *);
52 # define xmalloc(size) (XMALLOC_TRACE (xmalloc) ((size)))
53 # define xrealloc(ptr, size) (XMALLOC_TRACE (xrealloc) ((ptr), (size)))
54 # define xstrdup(str) (XMALLOC_TRACE (xstrdup) ((str)))
55 # define xfree(ptr) (XMALLOC_TRACE free ((ptr)))
57 #if defined(HAVE_GNU_MALLOC) && defined(DEBUG)
58 extern const char *tmalloc_tag;
59 # define XMALLOC_TRACE tmalloc_tag = __FILE__,
61 # define XMALLOC_TRACE
64 #endif /* _XMALLOC_H_ */