From bc1ca81d793c65b2177b7cc7a53d058a3929c11c Mon Sep 17 00:00:00 2001 From: marxin Date: Tue, 10 Nov 2015 12:27:33 +0000 Subject: [PATCH] Enhance pool allocator * alloc-pool.h (allocate_raw): New function. (operator new (size_t, object_allocator &a)): Use the function instead of object_allocator::allocate). git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230105 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/alloc-pool.h | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0763ca1719c5..103b87283f06 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-11-10 Martin Liska + + * alloc-pool.h (allocate_raw): New function. + (operator new (size_t, object_allocator &a)): Use the + function instead of object_allocator::allocate). + 2015-11-10 Ilya Enkovich * config/i386/sse.md (HALFMASKMODE): New attribute. diff --git a/gcc/alloc-pool.h b/gcc/alloc-pool.h index bf9b0ebd6ee4..38aff2849970 100644 --- a/gcc/alloc-pool.h +++ b/gcc/alloc-pool.h @@ -477,12 +477,25 @@ public: m_allocator.release_if_empty (); } + + /* Allocate memory for instance of type T and call a default constructor. */ + inline T * allocate () ATTRIBUTE_MALLOC { return ::new (m_allocator.allocate ()) T; } + /* Allocate memory for instance of type T and return void * that + could be used in situations where a default constructor is not provided + by the class T. */ + + inline void * + allocate_raw () ATTRIBUTE_MALLOC + { + return m_allocator.allocate (); + } + inline void remove (T *object) { @@ -528,7 +541,7 @@ template inline void * operator new (size_t, object_allocator &a) { - return a.allocate (); + return a.allocate_raw (); } /* Hashtable mapping alloc_pool names to descriptors. */ -- 2.47.2