* Change default constructor for BinaryWriter to accept null buffers

This commit is contained in:
Phillip Stephens 2014-09-19 18:16:17 -07:00
parent f92811004f
commit 8b80f486ad
2 changed files with 5 additions and 2 deletions

View File

@ -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.
*

View File

@ -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<void(int)> progressFun)
: m_length(0),