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.
30 /* xmalloc() & friends.
32 The macros set tmalloc_tag to __FILE__, the functions leave it
33 alone. Use the latter if you set it yourself. See tmalloc.c for
36 extern void *xmalloc (size_t);
37 extern void *xrealloc (void *, size_t);
38 extern char *xstrdup (const char *);
39 extern void xnomem (void);
40 extern void free (void *);
42 # define xmalloc(size) (XMALLOC_TRACE (xmalloc) ((size)))
43 # define xrealloc(ptr, size) (XMALLOC_TRACE (xrealloc) ((ptr), (size)))
44 # define xstrdup(str) (XMALLOC_TRACE (xstrdup) ((str)))
45 # define xfree(ptr) (XMALLOC_TRACE free ((ptr)))
47 #if defined(HAVE_GNU_MALLOC) && defined(DEBUG)
48 extern const char *tmalloc_tag;
49 # define XMALLOC_TRACE tmalloc_tag = __FILE__,
51 # define XMALLOC_TRACE
54 #endif /* _XMALLOC_H_ */