GCC Middle and Back End API Reference
auto-obstack.h
Go to the documentation of this file.
1/* RAII wrapper around obstack.
2 Copyright (C) 2024-2025 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it
8under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 3, or (at your option)
10any later version.
11
12GCC is distributed in the hope that it will be useful, but
13WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
20
21#ifndef GCC_AUTO_OBSTACK_H
22#define GCC_AUTO_OBSTACK_H
23
24/* RAII wrapper around obstack. */
25
27{
29 {
30 obstack_init (&m_obstack);
31 }
32
34 {
35 obstack_free (&m_obstack, NULL);
36 }
37
38 operator obstack & () { return m_obstack; }
39
40 void grow (const void *src, size_t length)
41 {
42 obstack_grow (&m_obstack, src, length);
43 }
44
45 void *object_base () const
46 {
47 return m_obstack.object_base;
48 }
49
50 size_t object_size () const
51 {
52 return obstack_object_size (&m_obstack);
53 }
54
56};
57
58#endif /* GCC_AUTO_OBSTACK_H */
static struct obstack obstack
Definition gcc.cc:364
void * object_base() const
Definition auto-obstack.h:45
~auto_obstack()
Definition auto-obstack.h:33
obstack m_obstack
Definition auto-obstack.h:55
void grow(const void *src, size_t length)
Definition auto-obstack.h:40
auto_obstack()
Definition auto-obstack.h:28
size_t object_size() const
Definition auto-obstack.h:50
#define NULL
Definition system.h:50