GDB (API)
|
00001 /* Obstack wrapper for GDB. 00002 00003 Copyright (C) 2002-2013 Free Software Foundation, Inc. 00004 00005 This file is part of GDB. 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 3 of the License, or 00010 (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00019 00020 #if !defined (GDB_OBSTACK_H) 00021 #define GDB_OBSTACK_H 1 00022 00023 #include "obstack.h" 00024 00025 /* Utility macros - wrap obstack alloc into something more robust. */ 00026 00027 #define OBSTACK_ZALLOC(OBSTACK,TYPE) \ 00028 (memset (obstack_alloc ((OBSTACK), sizeof (TYPE)), 0, sizeof (TYPE))) 00029 00030 #define OBSTACK_CALLOC(OBSTACK,NUMBER,TYPE) \ 00031 (memset (obstack_alloc ((OBSTACK), (NUMBER) * sizeof (TYPE)), \ 00032 0, (NUMBER) * sizeof (TYPE))) 00033 00034 /* Unless explicitly specified, GDB obstacks always use xmalloc() and 00035 xfree(). */ 00036 /* Note: ezannoni 2004-02-09: One could also specify the allocation 00037 functions using a special init function for each obstack, 00038 obstack_specify_allocation. However we just use obstack_init and 00039 let these defines here do the job. While one could argue the 00040 superiority of one approach over the other, we just chose one 00041 throughout. */ 00042 00043 #define obstack_chunk_alloc xmalloc 00044 #define obstack_chunk_free xfree 00045 00046 #define obstack_grow_str(OBSTACK,STRING) \ 00047 obstack_grow (OBSTACK, STRING, strlen (STRING)) 00048 #define obstack_grow_str0(OBSTACK,STRING) \ 00049 obstack_grow0 (OBSTACK, STRING, strlen (STRING)) 00050 00051 #define obstack_grow_wstr(OBSTACK, WSTRING) \ 00052 obstack_grow (OBSTACK, WSTRING, sizeof (gdb_wchar_t) * gdb_wcslen (WSTRING)) 00053 00054 /* Concatenate NULL terminated variable argument list of `const char 00055 *' strings; return the new string. Space is found in the OBSTACKP. 00056 Argument list must be terminated by a sentinel expression `(char *) 00057 NULL'. */ 00058 00059 extern char *obconcat (struct obstack *obstackp, ...) ATTRIBUTE_SENTINEL; 00060 00061 #endif