diff --git a/include/Athena/BinaryWriter.hpp b/include/Athena/BinaryWriter.hpp index dca0337..f7a6f1d 100644 --- a/include/Athena/BinaryWriter.hpp +++ b/include/Athena/BinaryWriter.hpp @@ -41,7 +41,7 @@ public: * \param data The existing buffer * \param length The length of the existing buffer */ - BinaryWriter(atUint8* data, atUint64 length); + explicit BinaryWriter(atUint8* data = nullptr, atUint64 length=0x10); /*! \brief This constructor creates an instance from a file on disk. * diff --git a/src/Athena/BinaryWriter.cpp b/src/Athena/BinaryWriter.cpp index 4f42bb0..e95f0d3 100644 --- a/src/Athena/BinaryWriter.cpp +++ b/src/Athena/BinaryWriter.cpp @@ -41,7 +41,10 @@ BinaryWriter::BinaryWriter(atUint8* data, atUint64 length) m_bitPosition(0), m_endian(Endian::LittleEndian), m_progressCallback(nullptr) -{} +{ + if (!m_data) + m_data = new atUint8[m_length]; +} BinaryWriter::BinaryWriter(const std::string& filename, std::function progressFun) : m_length(0),