From 6aa8519d86fb7d29325bed07046085c435876da2 Mon Sep 17 00:00:00 2001 From: Johannes Singler Date: Fri, 11 Sep 2009 16:33:58 +0000 Subject: [PATCH] 2009-09-11 Johannes Singler * include/parallel/multiway_merge.h (multiway_merge_exact_splitting): Deallocate borders correctly. (parallel_multiway_merge): Remove unnecessarily complicated allocation, random access iterators are default-constructible; deallocate ne_seqs correctly. From-SVN: r151640 --- libstdc++-v3/ChangeLog | 8 ++++++++ .../include/parallel/multiway_merge.h | 19 +++++++------------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 7d1ce936f70..8cb9560b54f 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2009-09-11 Johannes Singler + + * include/parallel/multiway_merge.h + (multiway_merge_exact_splitting): Deallocate borders correctly. + (parallel_multiway_merge): Remove unnecessarily complicated + allocation, random access iterators are default-constructible; + deallocate ne_seqs correctly. + 2009-09-11 Paolo Carlini PR libstdc++/41316 diff --git a/libstdc++-v3/include/parallel/multiway_merge.h b/libstdc++-v3/include/parallel/multiway_merge.h index bacff8dbadb..fe32053d6c1 100644 --- a/libstdc++-v3/include/parallel/multiway_merge.h +++ b/libstdc++-v3/include/parallel/multiway_merge.h @@ -1224,7 +1224,7 @@ void multiway_merge_exact_splitting( offsets[num_threads - 1].begin(), comp); } } - + delete[] borders; for (int slab = 0; slab < num_threads; ++slab) { @@ -1305,11 +1305,8 @@ template< std::iterator_traits::value_type value_type; // Leave only non-empty sequences. - std::pair* ne_seqs = - static_cast*>( - ::operator new( - sizeof(std::pair) - * (seqs_end - seqs_begin))); + typedef std::pair seq_type; + seq_type* ne_seqs = new seq_type[seqs_end - seqs_begin]; int k = 0; difference_type total_length = 0; for (RandomAccessIteratorIterator raii = seqs_begin; @@ -1319,9 +1316,7 @@ template< if(seq_length > 0) { total_length += seq_length; - //ne_seqs[k] = *raii; - new(&(ne_seqs[k++])) - std::pair(*raii); + ne_seqs[k++] = *raii; } } @@ -1331,7 +1326,7 @@ template< if (total_length == 0 || k == 0) { - ::operator delete(ne_seqs); + delete[] ne_seqs; return target; } @@ -1366,8 +1361,7 @@ template< for (int c = 0; c < k; ++c) target_position += pieces[iam][c].first; - std::pair* chunks - = new std::pair[k]; + seq_type* chunks = new seq_type[k]; for (int s = 0; s < k; ++s) { @@ -1399,6 +1393,7 @@ template< } delete[] pieces; + delete[] ne_seqs; return target + length; }