mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-01-19 15:01:49 +00:00
fix: crash on writing float44 type due to misaligned memory
* the compiler in release builds optimizes to use movaps * this opcode requires memory alignment to 16 byte * the written memory buffer may be misaligned at this position
This commit is contained in:
@@ -34,7 +34,9 @@ public:
|
|||||||
[[nodiscard]] ZoneStreamFillWriteAccessor AtOffset(size_t offset) const;
|
[[nodiscard]] ZoneStreamFillWriteAccessor AtOffset(size_t offset) const;
|
||||||
[[nodiscard]] ZoneOutputOffset Offset() const;
|
[[nodiscard]] ZoneOutputOffset Offset() const;
|
||||||
|
|
||||||
template<typename T> void Fill(const T& value, const size_t offset) const
|
template<typename T>
|
||||||
|
requires(sizeof(T) <= sizeof(uintptr_t))
|
||||||
|
void Fill(const T& value, const size_t offset) const
|
||||||
{
|
{
|
||||||
assert(m_block_buffer);
|
assert(m_block_buffer);
|
||||||
assert(offset + sizeof(T) <= m_buffer_size);
|
assert(offset + sizeof(T) <= m_buffer_size);
|
||||||
@@ -42,6 +44,16 @@ public:
|
|||||||
*reinterpret_cast<T*>(static_cast<char*>(m_block_buffer) + offset) = value;
|
*reinterpret_cast<T*>(static_cast<char*>(m_block_buffer) + offset) = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
requires(sizeof(T) > sizeof(uintptr_t))
|
||||||
|
void Fill(const T& value, const size_t offset) const
|
||||||
|
{
|
||||||
|
assert(m_block_buffer);
|
||||||
|
assert(offset + sizeof(T) <= m_buffer_size);
|
||||||
|
|
||||||
|
std::memcpy(static_cast<char*>(m_block_buffer) + offset, &value, sizeof(T));
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T, size_t S> void FillArray(T (&value)[S], const size_t offset) const
|
template<typename T, size_t S> void FillArray(T (&value)[S], const size_t offset) const
|
||||||
{
|
{
|
||||||
assert(m_block_buffer);
|
assert(m_block_buffer);
|
||||||
|
|||||||
Reference in New Issue
Block a user