Skip to content

Commit

Permalink
Merge pull request #1519 from evoskuil/master
Browse files Browse the repository at this point in the history
Change arena require to initialize, default to nullptr.
  • Loading branch information
evoskuil authored Aug 14, 2024
2 parents 773c958 + da5b88e commit 616e635
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions include/bitcoin/system/arena.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ class arena
return do_is_equal(other);
}

/// Require memory capacity, return current or nullptr (custom interface).
virtual void* require(size_t bytes) NOEXCEPT = 0;
/// Non-linear allocator is a nop and returns nullptr.
/// Reset linear allocator and return starting address (not pmr interface).
virtual void* initialize() NOEXCEPT = 0;

private:
virtual void* do_allocate(size_t bytes, size_t align) THROWS = 0;
Expand Down Expand Up @@ -82,7 +83,7 @@ class BC_API default_arena final
{
public:
static arena* get() NOEXCEPT;
void* require(size_t bytes) NOEXCEPT override;
void* initialize() NOEXCEPT override;

private:
void* do_allocate(size_t bytes, size_t align) THROWS override;
Expand Down
2 changes: 1 addition & 1 deletion src/arena.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ bool default_arena::do_is_equal(const arena& other) const NOEXCEPT
return &other == this;
}

void* default_arena::require(size_t) NOEXCEPT
void* default_arena::initialize() NOEXCEPT
{
return nullptr;
}
Expand Down
4 changes: 2 additions & 2 deletions test/test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class reporting_arena
size_t dec_count{};
size_t dec_bytes{};

void* require(size_t) NOEXCEPT override
void* initialize() NOEXCEPT override
{
return nullptr;
}
Expand Down Expand Up @@ -189,7 +189,7 @@ class mock_arena
size_t do_deallocate_align{};
mutable const arena* do_is_equal_address{};

void* require(size_t) NOEXCEPT override
void* initialize() NOEXCEPT override
{
return nullptr;
}
Expand Down

0 comments on commit 616e635

Please sign in to comment.