aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2015-10-26 09:48:32 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2015-10-26 09:48:32 +0000
commit5929c659186adc165b6cc32aab2890a1629d667a (patch)
treeda1ddcce6fe1aa85899bd7530b15d97fae837e40 /gcc
parent543a9bcd216d9a9fb377b7f84766cdcc858c21c0 (diff)
downloadgcc-5929c659186adc165b6cc32aab2890a1629d667a.zip
gcc-5929c659186adc165b6cc32aab2890a1629d667a.tar.gz
gcc-5929c659186adc165b6cc32aab2890a1629d667a.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/alloc-pool.h7
2 files changed, 10 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3285ca4..cf6e87f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/alloc-pool.h b/gcc/alloc-pool.h
index 404b558..0dc05cd 100644
--- a/gcc/alloc-pool.h
+++ b/gcc/alloc-pool.h
@@ -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));