Skip to content

Commit

Permalink
mini_heap: factor out isRelated() check
Browse files Browse the repository at this point in the history
  • Loading branch information
bpowers committed Oct 15, 2020
1 parent 9c183e3 commit 79ba561
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 1 addition & 8 deletions src/global_heap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,7 @@ void GlobalHeap::freeFor(MiniHeap *mh, void *ptr, size_t startEpoch) {
// check to make sure the new MiniHeap is related (via a
// meshing relationship) to the one we had before grabbing the
// lock.
auto origFound = false;
mh->forEachMeshed([&](const MiniHeap *eachMh) {
const auto found = eachMh == origMh;
origFound = found;
return found;
});

if (!origFound) {
if (!mh->isRelated(origMh)) {
// the original miniheap was freed and a new (unrelated)
// Miniheap allocated for the address space. nothing else
// for us to do.
Expand Down
10 changes: 10 additions & 0 deletions src/mini_heap.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,16 @@ class MiniHeap {
}
}

bool isRelated(MiniHeap *other) const {
auto otherFound = false;
this->forEachMeshed([&](const MiniHeap *eachMh) {
const auto found = eachMh == other;
otherFound = found;
return found;
});
return otherFound;
}

size_t meshCount() const {
size_t count = 0;

Expand Down

0 comments on commit 79ba561

Please sign in to comment.