--- a/src/dataBuffer.cpp Sun Jul 20 17:25:36 2014 +0300 +++ b/src/dataBuffer.cpp Mon Jul 21 17:14:42 2014 +0300 @@ -26,14 +26,15 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <cstring> #include "dataBuffer.h" // ------------------------------------------------------------------------------------------------- // DataBuffer::DataBuffer (int size) : m_buffer (new char[size]), - m_position (&buffer()[0]), - m_allocatedSize (size) {} + m_allocatedSize (size), + m_position (&buffer()[0]) {} // ------------------------------------------------------------------------------------------------- // @@ -162,12 +163,21 @@ // void DataBuffer::writeStringIndex (const String& a) { - writeDWord (DataHeader::PushStringIndex); + writeHeader (DataHeader::PushStringIndex); writeDWord (getStringTableIndex (a)); } // ------------------------------------------------------------------------------------------------- // +// Writes a data header. 4 bytes. +// +void DataBuffer::writeHeader (DataHeader data) +{ + writeDWord (static_cast<int32_t> (data)); +} + +// ------------------------------------------------------------------------------------------------- +// // Prints the buffer to stdout. // void DataBuffer::dump() @@ -192,7 +202,7 @@ // the stuff - thus resize. First, store the old // buffer temporarily: char* copy = new char[allocatedSize()]; - memcpy (copy, buffer(), allocatedSize()); + std::memcpy (copy, buffer(), allocatedSize()); // Remake the buffer with the new size. Have enough space // for the stuff we're going to write, as well as a bit @@ -204,7 +214,7 @@ setAllocatedSize (newsize); // Now, copy the stuff back. - memcpy (m_buffer, copy, allocatedSize()); + std::memcpy (m_buffer, copy, allocatedSize()); setPosition (buffer() + writesize); delete copy; }