From f51d2e7b7cab65dafb66202fea509d6e78430030 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 12 Dec 2025 13:12:56 -0500 Subject: [PATCH] xo-alloc2: mark Allocator.expand() noexcept --- xo-alloc2/include/xo/alloc2/AAllocator.hpp | 2 +- xo-alloc2/include/xo/alloc2/IAllocator_Any.hpp | 2 +- .../include/xo/alloc2/IAllocator_DArena.hpp | 16 ++++++++-------- xo-alloc2/include/xo/alloc2/IAllocator_Xfer.hpp | 2 +- xo-alloc2/src/alloc2/IAllocator_DArena.cpp | 16 ++++++++-------- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/xo-alloc2/include/xo/alloc2/AAllocator.hpp b/xo-alloc2/include/xo/alloc2/AAllocator.hpp index 4ff7cb5f..b0d82345 100644 --- a/xo-alloc2/include/xo/alloc2/AAllocator.hpp +++ b/xo-alloc2/include/xo/alloc2/AAllocator.hpp @@ -108,7 +108,7 @@ namespace xo { * to size at least @p z * In practice will round up to a multiple of hugepage size (2MB) **/ - virtual bool expand(Opaque d, std::size_t z) const = 0; + virtual bool expand(Opaque d, std::size_t z) const noexcept = 0; /** allocate @p z bytes of memory from allocator @p d. **/ virtual std::byte * alloc(Opaque d, std::size_t z) const = 0; /** reset allocator @p d to empty state **/ diff --git a/xo-alloc2/include/xo/alloc2/IAllocator_Any.hpp b/xo-alloc2/include/xo/alloc2/IAllocator_Any.hpp index ca7c5c6d..c8735f7b 100644 --- a/xo-alloc2/include/xo/alloc2/IAllocator_Any.hpp +++ b/xo-alloc2/include/xo/alloc2/IAllocator_Any.hpp @@ -39,7 +39,7 @@ namespace xo { [[noreturn]] size_type allocated(Copaque) const noexcept override { _fatal(); } [[noreturn]] bool contains(Copaque, const void *) const noexcept override { _fatal(); } - [[noreturn]] bool expand(Opaque, std::size_t) const override { _fatal(); } + [[noreturn]] bool expand(Opaque, std::size_t) const noexcept override { _fatal(); } [[noreturn]] std::byte * alloc(Opaque, std::size_t) const override { _fatal(); } [[noreturn]] void clear(Opaque) const override { _fatal(); } [[noreturn]] void destruct_data(Opaque) const override { _fatal(); } diff --git a/xo-alloc2/include/xo/alloc2/IAllocator_DArena.hpp b/xo-alloc2/include/xo/alloc2/IAllocator_DArena.hpp index bd5551ab..47886f42 100644 --- a/xo-alloc2/include/xo/alloc2/IAllocator_DArena.hpp +++ b/xo-alloc2/include/xo/alloc2/IAllocator_DArena.hpp @@ -30,19 +30,19 @@ namespace xo { struct IAllocator_DArena { using size_type = std::size_t; - static const std::string & name(const DArena &); - static size_type reserved(const DArena &); - static size_type size(const DArena &); - static size_type committed(const DArena &); - static size_type available(const DArena &); - static size_type allocated(const DArena &); - static bool contains(const DArena &, const void * p); + static const std::string & name(const DArena &) noexcept; + static size_type reserved(const DArena &) noexcept; + static size_type size(const DArena &) noexcept; + static size_type committed(const DArena &) noexcept; + static size_type available(const DArena &) noexcept; + static size_type allocated(const DArena &) noexcept; + static bool contains(const DArena &, const void * p) noexcept; /** expand committed space in arena @p d * to size at least @p z * In practice will round up to a multiple of @ref page_z_. **/ - static bool expand(DArena & d, std::size_t z); + static bool expand(DArena & d, std::size_t z) noexcept; static std::byte * alloc(const DArena &, std::size_t z); static void clear(DArena &); diff --git a/xo-alloc2/include/xo/alloc2/IAllocator_Xfer.hpp b/xo-alloc2/include/xo/alloc2/IAllocator_Xfer.hpp index f8438cad..4c498903 100644 --- a/xo-alloc2/include/xo/alloc2/IAllocator_Xfer.hpp +++ b/xo-alloc2/include/xo/alloc2/IAllocator_Xfer.hpp @@ -48,7 +48,7 @@ namespace xo { return Impl::contains(_dcast(d), p); } - bool expand(Opaque d, std::size_t z) const override { + bool expand(Opaque d, std::size_t z) const noexcept override { return Impl::expand(_dcast(d), z); } std::byte * alloc(Opaque d, std::size_t z) const override { diff --git a/xo-alloc2/src/alloc2/IAllocator_DArena.cpp b/xo-alloc2/src/alloc2/IAllocator_DArena.cpp index 2bb7f1d2..30ccd1db 100644 --- a/xo-alloc2/src/alloc2/IAllocator_DArena.cpp +++ b/xo-alloc2/src/alloc2/IAllocator_DArena.cpp @@ -16,44 +16,44 @@ namespace xo { namespace mm { const std::string & - IAllocator_DArena::name(const DArena & s) { + IAllocator_DArena::name(const DArena & s) noexcept { return s.config_.name_; } size_t - IAllocator_DArena::reserved(const DArena & s) { + IAllocator_DArena::reserved(const DArena & s) noexcept { return s.hi_ - s.lo_; } size_t - IAllocator_DArena::size(const DArena & s) { + IAllocator_DArena::size(const DArena & s) noexcept { return s.limit_ - s.lo_; } size_t - IAllocator_DArena::committed(const DArena & s) { + IAllocator_DArena::committed(const DArena & s) noexcept { return s.committed_z_; } size_t - IAllocator_DArena::available(const DArena & s) { + IAllocator_DArena::available(const DArena & s) noexcept { return s.limit_ - s.free_; } size_t - IAllocator_DArena::allocated(const DArena & s) { + IAllocator_DArena::allocated(const DArena & s) noexcept { return s.free_ - s.lo_; } bool IAllocator_DArena::contains(const DArena & s, - const void * p) + const void * p) noexcept { return (s.lo_ <= p) && (p < s.hi_); } bool - IAllocator_DArena::expand(DArena & s, size_t target_z) + IAllocator_DArena::expand(DArena & s, size_t target_z) noexcept { scope log(XO_DEBUG(s.config_.debug_flag_), xtag("target_z", target_z),