+2015-10-26 Richard Biener <rguenther@suse.de>
+
+ * alloc-pool.h (base_pool_allocator): Use placement new.
+ (base_pool_allocator::remove): Likewise. Compute size outside of
+ flag_checking.
+
2015-10-26 Richard Sandiford <richard.sandiford@arm.com>
* builtins.c (do_real_to_int_conversion): New function.
/* Make the block. */
block = reinterpret_cast<char *> (TBlockAllocator::allocate ());
- block_header = (allocation_pool_list*) block;
+ block_header = new (block) allocation_pool_list;
block += align_eight (sizeof (allocation_pool_list));
/* Throw it on the block list. */
inline void
base_pool_allocator <TBlockAllocator>::remove (void *object)
{
+ int size = m_elt_size - offsetof (allocation_object, u.data);
+
if (flag_checking)
{
gcc_assert (m_initialized);
/* Check whether the PTR was allocated from POOL. */
&& m_id == allocation_object::get_instance (object)->id);
- int size = m_elt_size - offsetof (allocation_object, u.data);
memset (object, 0xaf, size);
}
/* Mark the element to be free. */
allocation_object::get_instance (object)->id = 0;
- allocation_pool_list *header = (allocation_pool_list*) object;
+ allocation_pool_list *header = new (object) allocation_pool_list;
header->next = m_returned_free_list;
m_returned_free_list = header;
VALGRIND_DISCARD (VALGRIND_MAKE_MEM_NOACCESS (object, size));