diff options
author | Martin Liska <mliska@suse.cz> | 2015-11-10 13:27:33 +0100 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2015-11-10 12:27:33 +0000 |
commit | 8bd37a2ec9774884a4609a7832b2293f62936962 (patch) | |
tree | e3f101b43dd441f9e25403f1f28c3ccfca3bc5cc /gcc/alloc-pool.h | |
parent | bea408857a7d48d27024a1e0f7ce5074c7fd3ebb (diff) | |
download | gcc-8bd37a2ec9774884a4609a7832b2293f62936962.zip gcc-8bd37a2ec9774884a4609a7832b2293f62936962.tar.gz gcc-8bd37a2ec9774884a4609a7832b2293f62936962.tar.bz2 |
Enhance pool allocator
* alloc-pool.h (allocate_raw): New function.
(operator new (size_t, object_allocator<T> &a)): Use the
function instead of object_allocator::allocate).
From-SVN: r230105
Diffstat (limited to 'gcc/alloc-pool.h')
-rw-r--r-- | gcc/alloc-pool.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gcc/alloc-pool.h b/gcc/alloc-pool.h index bf9b0eb..38aff28 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 <typename T> inline void * operator new (size_t, object_allocator<T> &a) { - return a.allocate (); + return a.allocate_raw (); } /* Hashtable mapping alloc_pool names to descriptors. */ |