diff options
author | Alexander Tkachev | 2016-07-09 17:11:40 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | 30430b379fa373c277c3a64cfa03aa108b560476 (patch) | |
tree | ae6878851d608c47d79791f8208620b056e9d8d5 /backends/networking/sdl_net/client.cpp | |
parent | 36b0069e95a5eb6816e75bb9cf4aae56c7b5b258 (diff) | |
download | scummvm-rg350-30430b379fa373c277c3a64cfa03aa108b560476.tar.gz scummvm-rg350-30430b379fa373c277c3a64cfa03aa108b560476.tar.bz2 scummvm-rg350-30430b379fa373c277c3a64cfa03aa108b560476.zip |
CLOUD: Fix Client's buffer
Diffstat (limited to 'backends/networking/sdl_net/client.cpp')
-rw-r--r-- | backends/networking/sdl_net/client.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/backends/networking/sdl_net/client.cpp b/backends/networking/sdl_net/client.cpp index 3b3f45baaa..9d49480334 100644 --- a/backends/networking/sdl_net/client.cpp +++ b/backends/networking/sdl_net/client.cpp @@ -29,14 +29,19 @@ namespace Networking { -Client::Client() : _state(INVALID), _set(nullptr), _socket(nullptr), _handler(nullptr), _previousHandler(nullptr), _stream(nullptr) {} +Client::Client(): + _state(INVALID), _set(nullptr), _socket(nullptr), _handler(nullptr), + _previousHandler(nullptr), _stream(nullptr), _buffer(new byte[CLIENT_BUFFER_SIZE]) {} -Client::Client(SDLNet_SocketSet set, TCPsocket socket) : _state(INVALID), _set(nullptr), _socket(nullptr), _handler(nullptr), _previousHandler(nullptr), _stream(nullptr) { +Client::Client(SDLNet_SocketSet set, TCPsocket socket): + _state(INVALID), _set(nullptr), _socket(nullptr), _handler(nullptr), + _previousHandler(nullptr), _stream(nullptr), _buffer(new byte[CLIENT_BUFFER_SIZE]) { open(set, socket); } Client::~Client() { close(); + delete[] _buffer; } void Client::open(SDLNet_SocketSet set, TCPsocket socket) { @@ -65,16 +70,14 @@ bool Client::readMoreIfNeeded() { if (!_socket) return false; if (!SDLNet_SocketReady(_socket)) return false; - const uint32 BUFFER_SIZE = 16 * 1024; - byte buffer[BUFFER_SIZE]; - int bytes = SDLNet_TCP_Recv(_socket, buffer, BUFFER_SIZE); + int bytes = SDLNet_TCP_Recv(_socket, _buffer, CLIENT_BUFFER_SIZE); if (bytes <= 0) { warning("Client::readHeaders recv fail"); close(); return false; } - if (_stream->write(buffer, bytes) != bytes) { + if (_stream->write(_buffer, bytes) != bytes) { warning("failed to write() into MemoryReadWriteStream"); close(); return false; |