Skip to content

Commit 1c7ccec

Browse files
committed
Try only deleting samples outside storage.
1 parent afacf89 commit 1c7ccec

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/sample.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -466,24 +466,17 @@ sample *factory::pop_freelist() {
466466
}
467467

468468
factory::~factory() {
469-
// get pending samples
470-
std::vector<sample*> pending;
471469
sample *cur = tail_.load();
472-
473-
// add them without deleting
474470
while (cur) {
475-
if (cur != sentinel()) {
476-
pending.push_back(cur);
477-
}
478471
sample *next = cur->next_.load();
479-
cur = next;
480-
}
481472

482-
// now delete the samples
483-
for (sample* s : pending) {
484-
delete s;
485-
}
473+
// Only delete samples that are outside of storage area
474+
if (cur != sentinel() && (static_cast<void*>(cur) < storage_ ||
475+
static_cast<void*>(cur) >= storage_ + storage_size_))
476+
delete cur;
486477

478+
cur = next;
479+
}
487480
delete[] storage_;
488481
}
489482

0 commit comments

Comments
 (0)