diff --git a/deps/ox/src/ox/preloader/preloader.hpp b/deps/ox/src/ox/preloader/preloader.hpp index 079725c6..76fdcf9c 100644 --- a/deps/ox/src/ox/preloader/preloader.hpp +++ b/deps/ox/src/ox/preloader/preloader.hpp @@ -86,6 +86,10 @@ class Preloader: public ModelHandlerBase> { template constexpr ox::Error field(CRStringView, const T **val, std::size_t cnt) noexcept; + constexpr ox::Error startAlloc(std::size_t sz) noexcept; + + constexpr ox::Error endAlloc() noexcept; + constexpr ox::Error offsetPtrs(std::size_t offset) noexcept; [[nodiscard]] @@ -220,11 +224,23 @@ constexpr ox::Error Preloader::field(CRStringView, const T **val, std: return {}; } +template +constexpr ox::Error Preloader::startAlloc(std::size_t sz) noexcept { + oxRequire(p, ox::allocate(&m_writer, sz)); + return m_writer.seekp(p); +} + +template +constexpr ox::Error Preloader::endAlloc() noexcept { + return m_writer.seekp(0, ox::ios_base::end); +} + template constexpr ox::Error Preloader::offsetPtrs(std::size_t offset) noexcept { for (const auto &p : m_ptrs) { oxReturnError(m_writer.seekp(p.loc)); - oxReturnError(ox::serialize(&m_writer, PlatSpec::correctEndianness(p.value + offset))); + const auto val = PlatSpec::template correctEndianness(p.value + offset); + oxReturnError(ox::serialize(&m_writer, val)); } oxReturnError(m_writer.seekp(0, ox::ios_base::end)); return {};