merge from gcc
[deliverable/binutils-gdb.git] / gdb / gdb_obstack.h
index 237830e1768b0544b23d6c4edb154b54718e37d5..253fd199b0d4e62a2d8f92e861801ee3d957f784 100644 (file)
 
 #include "obstack.h"
 
+/* Utility macros - wrap obstack alloc into something more robust.  */
+
+#define OBSTACK_ZALLOC(OBSTACK,TYPE) (memset (obstack_alloc ((OBSTACK), sizeof (TYPE)), 0, sizeof (TYPE)))
+
+#define OBSTACK_CALLOC(OBSTACK,NUMBER,TYPE) (memset (obstack_alloc ((OBSTACK), (NUMBER) * sizeof (TYPE)), 0, (NUMBER) * sizeof (TYPE)))
+
 /* Unless explicitly specified, GDB obstacks always use xmalloc() and
    xfree().  */
+/* Note: ezannoni 2004-02-09: One could also specify the allocation
+   functions using a special init function for each obstack,
+   obstack_specify_allocation.  However we just use obstack_init and
+   let these defines here do the job.  While one could argue the
+   superiority of one approach over the other, we just chose one
+   throughout.  */
+
 #define obstack_chunk_alloc xmalloc
 #define obstack_chunk_free xfree
 
This page took 0.024076 seconds and 4 git commands to generate.