Skip to content
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

handle short writes #1289

Merged
merged 1 commit into from Dec 23, 2015
Merged

handle short writes #1289

merged 1 commit into from Dec 23, 2015

Conversation

gtalusan
Copy link
Contributor

Calling HTTPClient->getString() would call writeStream and this report back a short write on success because StreamString returns 0 on success.

igrr added a commit that referenced this pull request Dec 23, 2015
@igrr igrr merged commit 1c7b816 into esp8266:master Dec 23, 2015
@alltheblinkythings
Copy link
Contributor

alltheblinkythings commented Dec 23, 2015 via email

@alltheblinkythings
Copy link
Contributor

alltheblinkythings commented Dec 23, 2015 via email

@Links2004
Copy link
Collaborator

i think this shut be a faster one:

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

we can access the string buffer direct.

Links2004 added a commit to Links2004/Arduino that referenced this pull request Dec 23, 2015
@gtalusan
Copy link
Contributor Author

@Links2004 yes, memcpy works much better. Thanks!

@gtalusan
Copy link
Contributor Author

@alltheblinkythings yes, you're correct. A short write was a short write in my calling code no matter how many bytes were written, but I can see the need for better accounting. #1294 hopes to address this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants