diff --git a/deps/ox/src/ox/fs/filestore/nodebuffer.hpp b/deps/ox/src/ox/fs/filestore/nodebuffer.hpp index aaacc4d1..2080cc85 100644 --- a/deps/ox/src/ox/fs/filestore/nodebuffer.hpp +++ b/deps/ox/src/ox/fs/filestore/nodebuffer.hpp @@ -22,11 +22,11 @@ class __attribute__((packed)) NodeBuffer { ox::LittleEndian firstItem = 0; }; - struct ItemPtr: public ox::fs::Ptr { + struct ItemPtr: public ox::fs::Ptr { inline ItemPtr() = default; inline ItemPtr(void *dataStart, size_t dataSize, size_t itemOffset, size_t size): - Ptr(dataStart, dataSize, itemOffset, size) { + Ptr(dataStart, dataSize, itemOffset, size) { } inline ItemPtr(void *dataStart, size_t dataSize, size_t itemOffset) { diff --git a/deps/ox/src/ox/fs/filestore/ptr.hpp b/deps/ox/src/ox/fs/filestore/ptr.hpp index 24ca62d2..43b31550 100644 --- a/deps/ox/src/ox/fs/filestore/ptr.hpp +++ b/deps/ox/src/ox/fs/filestore/ptr.hpp @@ -13,7 +13,7 @@ namespace ox { namespace fs { -template +template class Ptr { private: @@ -47,62 +47,63 @@ class Ptr { }; -template -inline Ptr::Ptr(void *dataStart, size_t dataSize, size_t itemStart, size_t itemSize) { +template +inline Ptr::Ptr(void *dataStart, size_t dataSize, size_t itemStart, size_t itemSize) { init(dataStart, dataSize, itemStart, itemSize); } -template -inline bool Ptr::valid() const { +template +inline bool Ptr::valid() const { return m_dataStart and m_itemOffset; } -template -inline size_t Ptr::size() const { +template +inline size_t Ptr::size() const { return m_itemSize; } -template -inline size_t Ptr::offset() const { +template +inline size_t Ptr::offset() const { return m_itemOffset; } -template -inline size_t Ptr::end() { +template +inline size_t Ptr::end() { return m_itemOffset + m_itemSize; } -template -inline T *Ptr::operator->() const { +template +inline T *Ptr::operator->() const { ox_assert(valid(), "Invalid pointer access. (ox::fs::Ptr::operator->())"); return reinterpret_cast(m_dataStart + m_itemOffset); } -template -inline Ptr::operator T*() const { +template +inline Ptr::operator T*() const { return reinterpret_cast(m_dataStart + m_itemOffset); } -template -inline Ptr::operator size_t() const { +template +inline Ptr::operator size_t() const { if (valid()) { return m_itemOffset; } return 0; } -template -inline T &Ptr::operator*() const { +template +inline T &Ptr::operator*() const { ox_assert(valid(), "Invalid pointer dereference. (ox::fs::Ptr::operator*())"); return *static_cast(this); } -template -void Ptr::init(void *dataStart, size_t dataSize, size_t itemStart, size_t itemSize) { +template +void Ptr::init(void *dataStart, size_t dataSize, size_t itemStart, size_t itemSize) { // do some sanity checks before assuming this is valid m_dataStart = static_cast(dataStart); if (itemSize >= sizeof(T) and dataStart and + itemStart >= minOffset and itemStart + itemSize <= dataSize) { m_itemOffset = itemStart; m_itemSize = itemSize; diff --git a/deps/ox/src/ox/std/assert.cpp b/deps/ox/src/ox/std/assert.cpp index 7bf1d88d..5e5b107f 100644 --- a/deps/ox/src/ox/std/assert.cpp +++ b/deps/ox/src/ox/std/assert.cpp @@ -18,4 +18,4 @@ void oxAssert(const char *file, int line, bool pass, const char *msg) { std::abort(); } #endif -} \ No newline at end of file +}