Changed the xml::Socket buffer to a std::string. Seemed to have some memleaks before :)

This commit is contained in:
Daniel Önnerby 2009-01-09 09:21:47 +00:00
parent 5de89cb4f4
commit 605d66ae72
2 changed files with 6 additions and 3 deletions

View File

@ -93,7 +93,8 @@ bool SocketWriter::Write(const char* buffer,long bytes){
this->Flush();
}
CopyMemory(this->buffer.c_array()+this->bufferSize, buffer, bytes);
this->buffer.append(buffer,bytes);
//CopyMemory(this->buffer.c_array()+this->bufferSize, buffer, bytes);
this->bufferSize += bytes;
return !this->exited;
@ -103,10 +104,11 @@ void SocketWriter::Flush(){
if(this->bufferSize && !this->Exited()){
boost::system::error_code error;
try{
boost::asio::write(this->socket,boost::asio::buffer(this->buffer,this->bufferSize));
boost::asio::write(this->socket,boost::asio::buffer(this->buffer));
}catch(...){
this->exited = true;
}
this->buffer.clear();
this->bufferSize = 0;
}
}

View File

@ -77,7 +77,8 @@ class SocketWriter : public IWriteSupplier{
boost::asio::ip::tcp::socket &socket;
bool exited;
long bufferSize;
boost::array<char, 4096> buffer;
//boost::array<char, 4096> buffer;
std::string buffer;
long maxBufferSize;
};