From 2d2f6abfe57c87d941903917738ba9eba0d3104d Mon Sep 17 00:00:00 2001 From: Daniel Thornburgh Date: Wed, 17 Jul 2024 15:40:46 -0700 Subject: [PATCH] Default initializers to clean up constructors --- libc/src/__support/freelist_heap.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/libc/src/__support/freelist_heap.h b/libc/src/__support/freelist_heap.h index 463ac6a1fd59117..ee448c04cfb2271 100644 --- a/libc/src/__support/freelist_heap.h +++ b/libc/src/__support/freelist_heap.h @@ -51,13 +51,10 @@ template 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 region) - : is_initialized_(false), region_(region), heap_limit_{}, - freelist_(DEFAULT_BUCKETS), heap_stats_{} { + : region_(region), heap_limit_{} { heap_stats_.total_bytes = region.size(); } @@ -86,14 +83,14 @@ template class FreeListHeap { return ptr >= region_.begin() && ptr < region_.end(); } - bool is_initialized_; + bool is_initialized_ = false; cpp::span 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