diff --git a/src/snmalloc/global/globalalloc.h b/src/snmalloc/global/globalalloc.h index 7607e582a..ca9aaf509 100644 --- a/src/snmalloc/global/globalalloc.h +++ b/src/snmalloc/global/globalalloc.h @@ -120,11 +120,11 @@ namespace snmalloc count--; } alloc = AllocPool::iterate(alloc); + } - if (count != 0) - { - error("Error: two few allocators in use."); - } + if (count != 0) + { + error("Error: two few allocators in use."); } } diff --git a/src/test/func/teardown/teardown.cc b/src/test/func/teardown/teardown.cc index 02129374d..3ad56925d 100644 --- a/src/test/func/teardown/teardown.cc +++ b/src/test/func/teardown/teardown.cc @@ -112,6 +112,20 @@ void f(size_t size) fflush(stdout); } +void check_debug_in_use() +{ + { + auto a = snmalloc::get_scoped_allocator(); + snmalloc::debug_in_use(1); + { + auto b = snmalloc::get_scoped_allocator(); + snmalloc::debug_in_use(2); + } + snmalloc::debug_in_use(1); + } + snmalloc::debug_in_use(0); +} + int main(int, char**) { setup(); @@ -142,4 +156,6 @@ int main(int, char**) f(shifted(7) - 1); printf("\n"); } + + check_debug_in_use(); }