Commit 8bd37a2e by Martin Liska Committed by Martin Liska

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
parent bea40885
2015-11-10 Martin Liska <mliska@suse.cz>
* alloc-pool.h (allocate_raw): New function.
(operator new (size_t, object_allocator<T> &a)): Use the
function instead of object_allocator::allocate).
2015-11-10 Ilya Enkovich <enkovich.gnu@gmail.com> 2015-11-10 Ilya Enkovich <enkovich.gnu@gmail.com>
* config/i386/sse.md (HALFMASKMODE): New attribute. * config/i386/sse.md (HALFMASKMODE): New attribute.
...@@ -477,12 +477,25 @@ public: ...@@ -477,12 +477,25 @@ public:
m_allocator.release_if_empty (); m_allocator.release_if_empty ();
} }
/* Allocate memory for instance of type T and call a default constructor. */
inline T * inline T *
allocate () ATTRIBUTE_MALLOC allocate () ATTRIBUTE_MALLOC
{ {
return ::new (m_allocator.allocate ()) T; 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 inline void
remove (T *object) remove (T *object)
{ {
...@@ -528,7 +541,7 @@ template <typename T> ...@@ -528,7 +541,7 @@ template <typename T>
inline void * inline void *
operator new (size_t, object_allocator<T> &a) operator new (size_t, object_allocator<T> &a)
{ {
return a.allocate (); return a.allocate_raw ();
} }
/* Hashtable mapping alloc_pool names to descriptors. */ /* Hashtable mapping alloc_pool names to descriptors. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment