Skip to content

Commit

Permalink
fix the problem with sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
omicronrex committed Oct 5, 2023
1 parent d32a89b commit a3acf86
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/gm_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned int>(id));
if(b == NULL) return 0;
b->WriteData(string, strlen(string));
b->WriteDataGML(string, strlen(string));
return 1;
}

Expand Down

0 comments on commit a3acf86

Please sign in to comment.