33 const auto reserved = npot ? ReserveNPOT(length) : Reserve(length);
57 bool Allocation::ReserveNPOT(
size_t reserved) {
59 reserved = std::max<size_t>(4096u, reserved);
63 bool Allocation::Reserve(
size_t reserved) {
64 if (reserved <= reserved_) {
68 auto new_allocation = ::realloc(buffer_, reserved);
69 if (!new_allocation) {
77 buffer_ =
static_cast<uint8_t*
>(new_allocation);
85 if (contents ==
nullptr) {
89 auto allocation = std::make_shared<Allocation>();
90 if (!allocation->Truncate(length)) {
94 std::memmove(allocation->GetBuffer(), contents, length);
100 const std::shared_ptr<Allocation>& allocation) {
104 return std::make_shared<fml::NonOwnedMapping>(
105 reinterpret_cast<const uint8_t*
>(allocation->GetBuffer()),
106 allocation->GetLength(),
107 [allocation](
auto,
auto) {}
112 auto buffer = std::make_shared<std::string>(std::move(
string));
113 return std::make_unique<fml::NonOwnedMapping>(
114 reinterpret_cast<const uint8_t*
>(buffer->c_str()), buffer->length(),
115 [buffer](
auto,
auto) {});