gdb/gdb_obstack.c - gdb

Functions defined

Source code

  1. /* Obstack wrapper for GDB.

  2.    Copyright (C) 2013-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. #include "defs.h"
  15. #include "gdb_obstack.h"

  16. /* Concatenate NULL terminated variable argument list of `const char *'
  17.    strings; return the new string.  Space is found in the OBSTACKP.
  18.    Argument list must be terminated by a sentinel expression `(char *)
  19.    NULL'.  */

  20. char *
  21. obconcat (struct obstack *obstackp, ...)
  22. {
  23.   va_list ap;

  24.   va_start (ap, obstackp);
  25.   for (;;)
  26.     {
  27.       const char *s = va_arg (ap, const char *);

  28.       if (s == NULL)
  29.         break;

  30.       obstack_grow_str (obstackp, s);
  31.     }
  32.   va_end (ap);
  33.   obstack_1grow (obstackp, 0);

  34.   return obstack_finish (obstackp);
  35. }