Skip to content

StreamString SSO bugfix #2737

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions cores/esp32/StreamString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,28 @@
#include "StreamString.h"

size_t StreamString::write(const uint8_t *data, size_t size) {
if(size && data) {
if(reserve(length() + size + 1)) {
memcpy((void *) (wbuffer() + len()), (const void *) data, size);
setLen(len() + size);
*(wbuffer() + len()) = 0x00; // add null for string end
if (size && data) {
const unsigned int newlen = length() + size;
if (reserve(newlen + 1)) {
memcpy((void *)(wbuffer() + len()), (const void *)data, size);
setLen(newlen);
*(wbuffer() + newlen) = 0x00; // add null for string end
return size;
}
}
return 0;
}

size_t StreamString::write(uint8_t data) {
return concat((char) data);
return concat((char)data);
}

int StreamString::available() {
return length();
}

int StreamString::read() {
if(length()) {
if (length()) {
char c = charAt(0);
remove(0, 1);
return c;
Expand All @@ -54,7 +55,7 @@ int StreamString::read() {
}

int StreamString::peek() {
if(length()) {
if (length()) {
char c = charAt(0);
return c;
}
Expand Down