Commit 6aa8519d by Johannes Singler Committed by Johannes Singler

2009-09-11 Johannes Singler <singler@ira.uka.de>

        * 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
parent 603bb63e
2009-09-11 Johannes Singler <singler@ira.uka.de>
* 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 <paolo.carlini@oracle.com> 2009-09-11 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/41316 PR libstdc++/41316
......
...@@ -1224,7 +1224,7 @@ void multiway_merge_exact_splitting( ...@@ -1224,7 +1224,7 @@ void multiway_merge_exact_splitting(
offsets[num_threads - 1].begin(), comp); offsets[num_threads - 1].begin(), comp);
} }
} }
delete[] borders;
for (int slab = 0; slab < num_threads; ++slab) for (int slab = 0; slab < num_threads; ++slab)
{ {
...@@ -1305,11 +1305,8 @@ template< ...@@ -1305,11 +1305,8 @@ template<
std::iterator_traits<RandomAccessIterator1>::value_type value_type; std::iterator_traits<RandomAccessIterator1>::value_type value_type;
// Leave only non-empty sequences. // Leave only non-empty sequences.
std::pair<RandomAccessIterator1, RandomAccessIterator1>* ne_seqs = typedef std::pair<RandomAccessIterator1, RandomAccessIterator1> seq_type;
static_cast<std::pair<RandomAccessIterator1, RandomAccessIterator1>*>( seq_type* ne_seqs = new seq_type[seqs_end - seqs_begin];
::operator new(
sizeof(std::pair<RandomAccessIterator1, RandomAccessIterator1>)
* (seqs_end - seqs_begin)));
int k = 0; int k = 0;
difference_type total_length = 0; difference_type total_length = 0;
for (RandomAccessIteratorIterator raii = seqs_begin; for (RandomAccessIteratorIterator raii = seqs_begin;
...@@ -1319,9 +1316,7 @@ template< ...@@ -1319,9 +1316,7 @@ template<
if(seq_length > 0) if(seq_length > 0)
{ {
total_length += seq_length; total_length += seq_length;
//ne_seqs[k] = *raii; ne_seqs[k++] = *raii;
new(&(ne_seqs[k++]))
std::pair<RandomAccessIterator1, RandomAccessIterator1>(*raii);
} }
} }
...@@ -1331,7 +1326,7 @@ template< ...@@ -1331,7 +1326,7 @@ template<
if (total_length == 0 || k == 0) if (total_length == 0 || k == 0)
{ {
::operator delete(ne_seqs); delete[] ne_seqs;
return target; return target;
} }
...@@ -1366,8 +1361,7 @@ template< ...@@ -1366,8 +1361,7 @@ template<
for (int c = 0; c < k; ++c) for (int c = 0; c < k; ++c)
target_position += pieces[iam][c].first; target_position += pieces[iam][c].first;
std::pair<RandomAccessIterator1, RandomAccessIterator1>* chunks seq_type* chunks = new seq_type[k];
= new std::pair<RandomAccessIterator1, RandomAccessIterator1>[k];
for (int s = 0; s < k; ++s) for (int s = 0; s < k; ++s)
{ {
...@@ -1399,6 +1393,7 @@ template< ...@@ -1399,6 +1393,7 @@ template<
} }
delete[] pieces; delete[] pieces;
delete[] ne_seqs;
return target + length; return target + length;
} }
......
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