Skip to content

Commit

Permalink
Default initializers to clean up constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
mysterymath committed Jul 17, 2024
1 parent 266094a commit 2d2f6ab
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions libc/src/__support/freelist_heap.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,10 @@ template <size_t NUM_BUCKETS = DEFAULT_BUCKETS.size()> class FreeListHeap {
};

constexpr FreeListHeap()
: is_initialized_(false), region_(&_end, size_t{0}),
heap_limit_(&__libc_heap_limit), freelist_(DEFAULT_BUCKETS),
heap_stats_{} {}
: region_(&_end, size_t{0}), heap_limit_(&__libc_heap_limit) {}

constexpr FreeListHeap(span<cpp::byte> region)
: is_initialized_(false), region_(region), heap_limit_{},
freelist_(DEFAULT_BUCKETS), heap_stats_{} {
: region_(region), heap_limit_{} {
heap_stats_.total_bytes = region.size();
}

Expand Down Expand Up @@ -86,14 +83,14 @@ template <size_t NUM_BUCKETS = DEFAULT_BUCKETS.size()> class FreeListHeap {
return ptr >= region_.begin() && ptr < region_.end();
}

bool is_initialized_;
bool is_initialized_ = false;
cpp::span<cpp::byte> region_;

// Kept to initialize region_ by non-constexpr cast to size_t
cpp::byte *heap_limit_;

FreeListType freelist_;
HeapStats heap_stats_;
FreeListType freelist_{DEFAULT_BUCKETS};
HeapStats heap_stats_{};
};

template <size_t BUFF_SIZE, size_t NUM_BUCKETS = DEFAULT_BUCKETS.size()>
Expand Down

0 comments on commit 2d2f6ab

Please sign in to comment.