alloc-pool.h (base_pool_allocator): Use placement new.
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. From-SVN: r229312
This commit is contained in:
parent
543a9bcd21
commit
5929c65918
|
@ -1,3 +1,9 @@
|
|||
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.
|
||||
|
|
|
@ -363,7 +363,7 @@ base_pool_allocator <TBlockAllocator>::allocate ()
|
|||
|
||||
/* 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. */
|
||||
|
@ -414,6 +414,8 @@ template <typename TBlockAllocator>
|
|||
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);
|
||||
|
@ -423,14 +425,13 @@ base_pool_allocator <TBlockAllocator>::remove (void *object)
|
|||
/* 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));
|
||||
|
|
Loading…
Reference in New Issue