xo-alloc2: mark Allocator.expand() noexcept

This commit is contained in:
Roland Conybeare 2025-12-12 13:12:56 -05:00
commit f51d2e7b7c
5 changed files with 19 additions and 19 deletions

View file

@ -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 **/

View file

@ -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(); }

View file

@ -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 &);

View file

@ -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 {

View file

@ -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),