1b725ae77Skettenis /* Obstack wrapper for GDB. 2b725ae77Skettenis 3b725ae77Skettenis Copyright 2002 Free Software Foundation, Inc. 4b725ae77Skettenis 5b725ae77Skettenis This file is part of GDB. 6b725ae77Skettenis 7b725ae77Skettenis This program is free software; you can redistribute it and/or modify 8b725ae77Skettenis it under the terms of the GNU General Public License as published by 9b725ae77Skettenis the Free Software Foundation; either version 2 of the License, or 10b725ae77Skettenis (at your option) any later version. 11b725ae77Skettenis 12b725ae77Skettenis This program is distributed in the hope that it will be useful, 13b725ae77Skettenis but WITHOUT ANY WARRANTY; without even the implied warranty of 14b725ae77Skettenis MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15b725ae77Skettenis GNU General Public License for more details. 16b725ae77Skettenis 17b725ae77Skettenis You should have received a copy of the GNU General Public License 18b725ae77Skettenis along with this program; if not, write to the Free Software 19b725ae77Skettenis Foundation, Inc., 59 Temple Place - Suite 330, 20b725ae77Skettenis Boston, MA 02111-1307, USA. */ 21b725ae77Skettenis 22b725ae77Skettenis #if !defined (GDB_OBSTACK_H) 23b725ae77Skettenis #define GDB_OBSTACK_H 1 24b725ae77Skettenis 25b725ae77Skettenis #include "obstack.h" 26b725ae77Skettenis 27*11efff7fSkettenis /* Utility macros - wrap obstack alloc into something more robust. */ 28*11efff7fSkettenis 29*11efff7fSkettenis #define OBSTACK_ZALLOC(OBSTACK,TYPE) (memset (obstack_alloc ((OBSTACK), sizeof (TYPE)), 0, sizeof (TYPE))) 30*11efff7fSkettenis 31*11efff7fSkettenis #define OBSTACK_CALLOC(OBSTACK,NUMBER,TYPE) (memset (obstack_alloc ((OBSTACK), (NUMBER) * sizeof (TYPE)), 0, (NUMBER) * sizeof (TYPE))) 32*11efff7fSkettenis 33b725ae77Skettenis /* Unless explicitly specified, GDB obstacks always use xmalloc() and 34b725ae77Skettenis xfree(). */ 35b725ae77Skettenis /* Note: ezannoni 2004-02-09: One could also specify the allocation 36b725ae77Skettenis functions using a special init function for each obstack, 37b725ae77Skettenis obstack_specify_allocation. However we just use obstack_init and 38b725ae77Skettenis let these defines here do the job. While one could argue the 39b725ae77Skettenis superiority of one approach over the other, we just chose one 40b725ae77Skettenis throughout. */ 41b725ae77Skettenis 42b725ae77Skettenis #define obstack_chunk_alloc xmalloc 43b725ae77Skettenis #define obstack_chunk_free xfree 44b725ae77Skettenis 45b725ae77Skettenis #endif 46