diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 4106d0a..939d02e 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -428,6 +428,14 @@ std::string Buffer::ReadData(unsigned int bytes) { } void Buffer::WriteData(const char* str, unsigned int len) { + if(len != 0) { + unsigned int p = length; + SetLength(length + len); + memcpy(data + p, str, len); + } +} + +void Buffer::WriteDataGML(const char* str, unsigned int len) { if(len != 0) { if (pos + len > length) { SetLength(pos + len); diff --git a/src/Buffer.h b/src/Buffer.h index c88e125..eda2d99 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -62,6 +62,7 @@ class Buffer { void WriteString(const char* str); std::string ReadData(unsigned int bytes); void WriteData(const char* str, unsigned int len); + void WriteDataGML(const char* str, unsigned int len); std::string ReadHex(unsigned int bytes); void WriteHex(const char* str, unsigned int len); std::string ReadBase64(unsigned int bytes); diff --git a/src/gm_buffer.cpp b/src/gm_buffer.cpp index b6a1e3e..fb6a9f1 100644 --- a/src/gm_buffer.cpp +++ b/src/gm_buffer.cpp @@ -341,7 +341,7 @@ gmexport const char* buffer_read_data(double id, double len) { gmexport double buffer_write_data(double id, const char* string) { Buffer *b = gmdata.FindBuffer(gm_cast(id)); if(b == NULL) return 0; - b->WriteData(string, strlen(string)); + b->WriteDataGML(string, strlen(string)); return 1; }