Skip to content

Commit

Permalink
fix(container): fix compilation with QLJS_DEBUG=1
Browse files Browse the repository at this point in the history
When compiled with QLJS_DEBUG=1, Linked_Bump_Allocator enables extra
checking. This checking code does not compile. Fix these build errors.
  • Loading branch information
strager committed Nov 4, 2023
1 parent bfebe9f commit 67da3d4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/quick-lint-js/container/linked-bump-allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,15 @@ class Linked_Bump_Allocator final : public Memory_Resource {

private:
#if QLJS_DEBUG_BUMP_ALLOCATOR
explicit disable_guard(linked_bump_allocator* alloc) : alloc_(alloc) {
explicit Disable_Guard(Linked_Bump_Allocator* alloc) : alloc_(alloc) {
this->alloc_->disabled_count_ += 1;
}
#else
explicit Disable_Guard(Linked_Bump_Allocator*) {}
#endif

#if QLJS_DEBUG_BUMP_ALLOCATOR
linked_bump_allocator* alloc_;
Linked_Bump_Allocator* alloc_;
#endif

friend class Linked_Bump_Allocator;
Expand Down
4 changes: 2 additions & 2 deletions test/test-linked-bump-allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ TEST(Test_Linked_Bump_Allocator, non_last_allocation_cannot_grow) {
(defined(GTEST_HAS_DEATH_TEST) && GTEST_HAS_DEATH_TEST)
TEST(Test_Linked_Bump_Allocator, cannot_allocate_when_disabled) {
auto check = [] {
linked_bump_allocator<1> alloc("test");
Linked_Bump_Allocator alloc("test");
auto disable_guard = alloc.disable();
// The following line should crash:
[[maybe_unused]] char* c = alloc.new_object<char>();
Expand All @@ -308,7 +308,7 @@ TEST(Test_Linked_Bump_Allocator, cannot_allocate_when_disabled) {

#if QLJS_DEBUG_BUMP_ALLOCATOR
TEST(Test_Linked_Bump_Allocator, can_allocate_after_disabling_then_reenabling) {
linked_bump_allocator<1> alloc("test");
Linked_Bump_Allocator alloc("test");
{
auto disable_guard = alloc.disable();
// Destruct disable_guard, re-enabling allocation.
Expand Down

0 comments on commit 67da3d4

Please sign in to comment.