diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2023-02-08 15:36:23 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2023-02-08 15:46:02 -0500 |
commit | c583a2520616c2736cffc389c89a48b159366e6c (patch) | |
tree | b4925f26506fcee96c16119431c01760f05db95d /gdbsupport/gdb_obstack.h | |
parent | ca7f92c2f15b86b09c4a8ad14806bef666308d31 (diff) | |
download | gdb-users/simark/clang-format.zip gdb-users/simark/clang-format.tar.gz gdb-users/simark/clang-format.tar.bz2 |
Run clang-format.shusers/simark/clang-format
Change-Id: Ia948cc26d534b0dd02702244d52434b1a2093968
Diffstat (limited to 'gdbsupport/gdb_obstack.h')
-rw-r--r-- | gdbsupport/gdb_obstack.h | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/gdbsupport/gdb_obstack.h b/gdbsupport/gdb_obstack.h index dbd8fab..00d32db 100644 --- a/gdbsupport/gdb_obstack.h +++ b/gdbsupport/gdb_obstack.h @@ -17,15 +17,15 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#if !defined (GDB_OBSTACK_H) +#if !defined(GDB_OBSTACK_H) #define GDB_OBSTACK_H 1 #include "obstack.h" /* Utility macros - wrap obstack alloc into something more robust. */ -template <typename T> -static inline T* +template<typename T> +static inline T * obstack_zalloc (struct obstack *ob) { static_assert (IsMallocable<T>::value, "Trying to use OBSTACK_ZALLOC with a \ @@ -33,28 +33,28 @@ non-POD data type. Use obstack_new instead."); return ((T *) memset (obstack_alloc (ob, sizeof (T)), 0, sizeof (T))); } -#define OBSTACK_ZALLOC(OBSTACK,TYPE) obstack_zalloc<TYPE> ((OBSTACK)) +#define OBSTACK_ZALLOC(OBSTACK, TYPE) obstack_zalloc<TYPE> ((OBSTACK)) -template <typename T> +template<typename T> static inline T * obstack_calloc (struct obstack *ob, size_t number) { static_assert (IsMallocable<T>::value, "Trying to use OBSTACK_CALLOC with a \ non-POD data type. Use obstack_new instead."); return ((T *) memset (obstack_alloc (ob, number * sizeof (T)), 0, - number * sizeof (T))); + number * sizeof (T))); } -#define OBSTACK_CALLOC(OBSTACK,NUMBER,TYPE) \ +#define OBSTACK_CALLOC(OBSTACK, NUMBER, TYPE) \ obstack_calloc<TYPE> ((OBSTACK), (NUMBER)) /* Allocate an object on OB and call its constructor. */ -template <typename T, typename... Args> -static inline T* -obstack_new (struct obstack *ob, Args&&... args) +template<typename T, typename... Args> +static inline T * +obstack_new (struct obstack *ob, Args &&...args) { - T* object = (T *) obstack_alloc (ob, sizeof (T)); + T *object = (T *) obstack_alloc (ob, sizeof (T)); object = new (object) T (std::forward<Args> (args)...); return object; } @@ -71,9 +71,9 @@ obstack_new (struct obstack *ob, Args&&... args) #define obstack_chunk_alloc xmalloc #define obstack_chunk_free xfree -#define obstack_grow_str(OBSTACK,STRING) \ +#define obstack_grow_str(OBSTACK, STRING) \ obstack_grow (OBSTACK, STRING, strlen (STRING)) -#define obstack_grow_str0(OBSTACK,STRING) \ +#define obstack_grow_str0(OBSTACK, STRING) \ obstack_grow0 (OBSTACK, STRING, strlen (STRING)) #define obstack_grow_wstr(OBSTACK, WSTRING) \ @@ -101,8 +101,7 @@ obstack_strdup (struct obstack *obstackp, const char *string) static inline char * obstack_strdup (struct obstack *obstackp, const std::string &string) { - return (char *) obstack_copy0 (obstackp, string.c_str (), - string.size ()); + return (char *) obstack_copy0 (obstackp, string.c_str (), string.size ()); } /* Duplicate the first N characters of STRING, returning a @@ -119,18 +118,15 @@ obstack_strndup (struct obstack *obstackp, const char *string, size_t n) /* An obstack that frees itself on scope exit. */ struct auto_obstack : obstack { - auto_obstack () - { obstack_init (this); } + auto_obstack () { obstack_init (this); } - ~auto_obstack () - { obstack_free (this, NULL); } + ~auto_obstack () { obstack_free (this, NULL); } DISABLE_COPY_AND_ASSIGN (auto_obstack); /* Free all memory in the obstack but leave it valid for further allocation. */ - void clear () - { obstack_free (this, obstack_base (this)); } + void clear () { obstack_free (this, obstack_base (this)); } }; /* Objects are allocated on obstack instead of heap. */ @@ -139,12 +135,12 @@ struct allocate_on_obstack { allocate_on_obstack () = default; - void* operator new (size_t size, struct obstack *obstack) + void *operator new (size_t size, struct obstack *obstack) { return obstack_alloc (obstack, size); } - void* operator new[] (size_t size, struct obstack *obstack) + void *operator new[] (size_t size, struct obstack *obstack) { return obstack_alloc (obstack, size); } |