summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>2008-06-24 01:42:31 +0000
committerghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>2008-06-24 01:42:31 +0000
commitb60b4740814c825022838c04dc7009661f31f625 (patch)
tree0cd6318463ccb586c88eabe8a770ff46194e4e44 /include
parenta19cd5272ec7903d4241a3ee8cb69e2de670e6b7 (diff)
downloadgcc-b60b4740814c825022838c04dc7009661f31f625.tar.gz
* libiberty.h (XALLOCA, XDUP, XALLOCAVEC, XDUPVEC, XALLOCAVAR,
XDUPVAR, XOBNEWVEC, XOBNEWVAR): New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@137058 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'include')
-rw-r--r--include/ChangeLog5
-rw-r--r--include/libiberty.h8
2 files changed, 13 insertions, 0 deletions
diff --git a/include/ChangeLog b/include/ChangeLog
index 2ace7e097ea..bf1af8da2cc 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,8 @@
+2008-06-23 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * libiberty.h (XALLOCA, XDUP, XALLOCAVEC, XDUPVEC, XALLOCAVAR,
+ XDUPVAR, XOBNEWVEC, XOBNEWVAR): New.
+
2008-03-24 Ian Lance Taylor <iant@google.com>
* sha1.h: New file, from gnulib.
diff --git a/include/libiberty.h b/include/libiberty.h
index 6ea8761fcd1..e3eca9d75cc 100644
--- a/include/libiberty.h
+++ b/include/libiberty.h
@@ -320,26 +320,34 @@ extern double physmem_available (void);
/* Scalar allocators. */
+#define XALLOCA(T) ((T *) alloca (sizeof (T)))
#define XNEW(T) ((T *) xmalloc (sizeof (T)))
#define XCNEW(T) ((T *) xcalloc (1, sizeof (T)))
+#define XDUP(T, P) ((T *) xmemdup ((P), sizeof (T), sizeof (T)))
#define XDELETE(P) free ((void*) (P))
/* Array allocators. */
+#define XALLOCAVEC(T, N) ((T *) alloca (sizeof (T) * (N)))
#define XNEWVEC(T, N) ((T *) xmalloc (sizeof (T) * (N)))
#define XCNEWVEC(T, N) ((T *) xcalloc ((N), sizeof (T)))
+#define XDUPVEC(T, P, N) ((T *) xmemdup ((P), sizeof (T) * (N), sizeof (T) * (N)))
#define XRESIZEVEC(T, P, N) ((T *) xrealloc ((void *) (P), sizeof (T) * (N)))
#define XDELETEVEC(P) free ((void*) (P))
/* Allocators for variable-sized structures and raw buffers. */
+#define XALLOCAVAR(T, S) ((T *) alloca ((S)))
#define XNEWVAR(T, S) ((T *) xmalloc ((S)))
#define XCNEWVAR(T, S) ((T *) xcalloc (1, (S)))
+#define XDUPVAR(T, P, S1, S2) ((T *) xmemdup ((P), (S1), (S2)))
#define XRESIZEVAR(T, P, S) ((T *) xrealloc ((P), (S)))
/* Type-safe obstack allocator. */
#define XOBNEW(O, T) ((T *) obstack_alloc ((O), sizeof (T)))
+#define XOBNEWVEC(O, T, N) ((T *) obstack_alloc ((O), sizeof (T) * (N)))
+#define XOBNEWVAR(O, T, S) ((T *) obstack_alloc ((O), (S)))
#define XOBFINISH(O, T) ((T) obstack_finish ((O)))
/* hex character manipulation routines */