Commit c13287b9 authored by Cyprien Borée's avatar Cyprien Borée

delete memory only if allocated

For more informations, see #3393.
parent 6c00a4f7
Pipeline #34684 failed with stages
in 2 minutes and 46 seconds
......@@ -53,9 +53,15 @@ void BinReadStorage::reallocate(){
}
}
}
delete [] bins;
delete [] score_bins;
delete [] nb_scores;
if(bins){
delete [] bins;
}
if(score_bins){
delete [] score_bins;
}
if(nb_scores){
delete [] nb_scores;
}
bins = new_bins;
score_bins = new_score_bins;
nb_scores = new_nb_scores;
......@@ -95,6 +101,9 @@ void BinReadStorage::add(Sequence &s) {
size_t bin = scoreToBin(score);
addScore(bin, score);
all_read_lengths += s.sequence.length();
if(nb_inserted >= nb_stored){
reallocate();
}
if (nb_stored < getMaxNbReadsStored()) {
bins[bin].push_back(s);
nb_stored++;
......@@ -103,9 +112,6 @@ void BinReadStorage::add(Sequence &s) {
} else {
// We don't have space left.
// Either we don't insert that sequence or it replaces another one
if(nb_inserted > nb_stored){
reallocate();
}
if (bin > smallest_bin_not_empty) {
bins[smallest_bin_not_empty].erase(bins[smallest_bin_not_empty].begin());
if (bins[smallest_bin_not_empty].size() == 0)
......
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