Fix cbuf not being able to hold the full length

fixes: https://github.com/espressif/arduino-esp32/issues/145
This commit is contained in:
me-no-dev 2017-01-24 17:57:44 +02:00
parent 5f203e1a98
commit 6a1e7c1e99

View File

@ -21,7 +21,7 @@
#include "cbuf.h" #include "cbuf.h"
cbuf::cbuf(size_t size) : cbuf::cbuf(size_t size) :
next(NULL), _size(size), _buf(new char[size]), _bufend(_buf + size), _begin(_buf), _end(_begin) next(NULL), _size(size+1), _buf(new char[size+1]), _bufend(_buf + size + 1), _begin(_buf), _end(_begin)
{ {
} }
@ -39,7 +39,7 @@ size_t cbuf::resize(size_t newSize)
{ {
size_t bytes_available = available(); size_t bytes_available = available();
newSize += 1;
// not lose any data // not lose any data
// if data can be lost use remove or flush before resize // if data can be lost use remove or flush before resize
if((newSize < bytes_available) || (newSize == _size)) { if((newSize < bytes_available) || (newSize == _size)) {