Fix register_clean_up being called with ScopedAllocator. (#344)
This commit is contained in:
committed by
GitHub
parent
f0e2ab702a
commit
4b9ead8066
@@ -25,7 +25,10 @@ namespace snmalloc
|
|||||||
/**
|
/**
|
||||||
* Constructor. Claims an allocator from the global pool
|
* 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
|
* Copying is not supported, it could easily lead to accidental sharing of
|
||||||
|
|||||||
@@ -37,4 +37,15 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ThreadAlloc::get().teardown();
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user