1*ef5ccd6cSJohn Marino /* Obstack wrapper for GDB. 2*ef5ccd6cSJohn Marino 3*ef5ccd6cSJohn Marino Copyright (C) 2013 Free Software Foundation, Inc. 4*ef5ccd6cSJohn Marino 5*ef5ccd6cSJohn Marino This file is part of GDB. 6*ef5ccd6cSJohn Marino 7*ef5ccd6cSJohn Marino This program is free software; you can redistribute it and/or modify 8*ef5ccd6cSJohn Marino it under the terms of the GNU General Public License as published by 9*ef5ccd6cSJohn Marino the Free Software Foundation; either version 3 of the License, or 10*ef5ccd6cSJohn Marino (at your option) any later version. 11*ef5ccd6cSJohn Marino 12*ef5ccd6cSJohn Marino This program is distributed in the hope that it will be useful, 13*ef5ccd6cSJohn Marino but WITHOUT ANY WARRANTY; without even the implied warranty of 14*ef5ccd6cSJohn Marino MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*ef5ccd6cSJohn Marino GNU General Public License for more details. 16*ef5ccd6cSJohn Marino 17*ef5ccd6cSJohn Marino You should have received a copy of the GNU General Public License 18*ef5ccd6cSJohn Marino along with this program. If not, see <http://www.gnu.org/licenses/>. */ 19*ef5ccd6cSJohn Marino 20*ef5ccd6cSJohn Marino #include "defs.h" 21*ef5ccd6cSJohn Marino #include "gdb_obstack.h" 22*ef5ccd6cSJohn Marino 23*ef5ccd6cSJohn Marino /* Concatenate NULL terminated variable argument list of `const char *' 24*ef5ccd6cSJohn Marino strings; return the new string. Space is found in the OBSTACKP. 25*ef5ccd6cSJohn Marino Argument list must be terminated by a sentinel expression `(char *) 26*ef5ccd6cSJohn Marino NULL'. */ 27*ef5ccd6cSJohn Marino 28*ef5ccd6cSJohn Marino char * 29*ef5ccd6cSJohn Marino obconcat (struct obstack *obstackp, ...) 30*ef5ccd6cSJohn Marino { 31*ef5ccd6cSJohn Marino va_list ap; 32*ef5ccd6cSJohn Marino 33*ef5ccd6cSJohn Marino va_start (ap, obstackp); 34*ef5ccd6cSJohn Marino for (;;) 35*ef5ccd6cSJohn Marino { 36*ef5ccd6cSJohn Marino const char *s = va_arg (ap, const char *); 37*ef5ccd6cSJohn Marino 38*ef5ccd6cSJohn Marino if (s == NULL) 39*ef5ccd6cSJohn Marino break; 40*ef5ccd6cSJohn Marino 41*ef5ccd6cSJohn Marino obstack_grow_str (obstackp, s); 42*ef5ccd6cSJohn Marino } 43*ef5ccd6cSJohn Marino va_end (ap); 44*ef5ccd6cSJohn Marino obstack_1grow (obstackp, 0); 45*ef5ccd6cSJohn Marino 46*ef5ccd6cSJohn Marino return obstack_finish (obstackp); 47*ef5ccd6cSJohn Marino } 48