ggc.h (GGC_NEW, [...]): New macros.
authorBernardo Innocenti <bernie@develer.com>
Sun, 25 Jul 2004 00:20:14 +0000 (02:20 +0200)
committerBernardo Innocenti <bernie@gcc.gnu.org>
Sun, 25 Jul 2004 00:20:14 +0000 (02:20 +0200)
* ggc.h (GGC_NEW, GGC_CNEW, GGC_NEWVEC, GGC_CNEWVEC, GGC_NEWVAR,
GGC_CNEWVAR): New macros.

From-SVN: r85133

gcc/ChangeLog
gcc/ggc.h

index 318b03f..cb9bea2 100644 (file)
@@ -1,5 +1,10 @@
 2004-07-25  Bernardo Innocenti  <bernie@develer.com>
 
+       * ggc.h (GGC_NEW, GGC_CNEW, GGC_NEWVEC, GGC_CNEWVEC, GGC_NEWVAR,
+       GGC_CNEWVAR): New macros.
+
+2004-07-25  Bernardo Innocenti  <bernie@develer.com>
+
        * c-common.c: Convert ATTRIBUTE_UNUSED to ARG_UNUSED in parameter
        lists.
        * c-decl.c: Likewise.
index 4ce271a..821de0c 100644 (file)
--- a/gcc/ggc.h
+++ b/gcc/ggc.h
@@ -237,6 +237,14 @@ extern void ggc_record_overhead (size_t, size_t MEM_STAT_DECL);
 
 extern void dump_ggc_loc_statistics (void);
 
+/* Type-safe, C++-friendly versions of ggc_alloc() and gcc_calloc().  */
+#define GGC_NEW(T)             ((T *) ggc_alloc (sizeof (T)))
+#define GGC_CNEW(T)            ((T *) ggc_alloc_cleared (sizeof (T)))
+#define GGC_NEWVEC(T, N)       ((T *) ggc_alloc ((N) * sizeof(T)))
+#define GGC_CNEWVEC(T, N)      ((T *) ggc_alloc_cleared ((N) * sizeof(T)))
+#define GGC_NEWVAR(T, S)       ((T *) ggc_alloc ((S)))
+#define GGC_CNEWVAR(T, S)      ((T *) ggc_alloc_cleared ((S)))
+
 #define ggc_alloc_rtx(CODE)                    \
   ((rtx) ggc_alloc_typed (gt_ggc_e_7rtx_def, RTX_SIZE (CODE)))