Fix register_clean_up being called with ScopedAllocator. (#344)

This commit is contained in:
Matthew Parkinson
2021-07-12 19:50:36 +01:00
committed by GitHub
parent f0e2ab702a
commit 4b9ead8066
2 changed files with 15 additions and 1 deletions

View File

@@ -25,7 +25,10 @@ namespace snmalloc
/**
* Constructor. Claims an allocator from the global pool
*/
ScopedAllocator() = default;
ScopedAllocator()
{
alloc.init();
};
/**
* Copying is not supported, it could easily lead to accidental sharing of

View File

@@ -37,4 +37,15 @@ int main()
}
ThreadAlloc::get().teardown();
// This checks that the scoped allocator does not call
// register clean up, as this configuration will fault
// if that occurs.
auto a2 = ScopedAllocator();
for (size_t i = 0; i < 1000; i++)
{
auto r1 = a2->alloc(i);
a2->dealloc(r1);
}
}