22#include "pw_assert/assert.h"
23#include "pw_bloat/bloat_this_binary.h"
24#include "pw_bytes/span.h"
26#ifndef PW_ALLOCATOR_SIZE_REPORTER_BASE
27#include "pw_allocator/allocator.h"
28#include "pw_allocator/null_allocator.h"
31namespace pw::allocator {
47 std::array<std::byte, 16> buffer;
55 Bar(
size_t number_) : number(number_) {
56 std::memset(foo.buffer.data(), 0, foo.buffer.size());
67 pw::bloat::BloatThisBinary();
68 ByteSpan bytes = buffer();
69 Bar* bar =
new (bytes.data())
Bar(0);
70 PW_ASSERT(bar !=
nullptr);
72#ifndef PW_ALLOCATOR_SIZE_REPORTER_BASE
74 Allocator& allocator = GetNullAllocator();
75 PW_ASSERT(allocator.
Allocate(Layout::Of<Foo>()) ==
nullptr);
79 ByteSpan buffer() {
return buffer_; }
81#ifndef PW_ALLOCATOR_SIZE_REPORTER_BASE
88 Layout layout = Layout::Of<Foo>();
91 void* ptr = allocator.
Allocate(layout);
97 ptr = allocator.
Reallocate(ptr, Layout::Of<Baz>());
103 Foo* foo = allocator.template New<Foo>();
110 PW_ASSERT(ptr ==
nullptr || unique_foo !=
nullptr);
115 std::array<std::byte, 0x400> buffer_;
Definition: allocator.h:32
bool Resize(void *ptr, size_t new_size)
Definition: allocator.h:81
void * Reallocate(void *ptr, Layout new_layout)
Definition: allocator.h:115
void * Allocate(Layout layout)
Definition: allocator.h:40
void Deallocate(void *ptr)
Definition: deallocator.h:47
void Delete(T *ptr)
Definition: deallocator.h:69
Definition: unique_ptr.h:47
Definition: size_reporter.h:43
void Measure(Allocator &allocator)
Definition: size_reporter.h:86
Nested type used for exercising an allocator.
Definition: size_reporter.h:51
Nested type used for exercising an allocator.
Definition: size_reporter.h:61
Nested type used for exercising an allocator.
Definition: size_reporter.h:46