-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Make SSO support \0s, use memmove, add test #6155
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
Make SSO support \0s, use memmove, add test #6155
Conversation
Supercedes esp8266#6027 Make SSO more generic by keeping track of its length explicitly, allowing for embedded \0s to exist in the String (just like the non-SSO ones).
Use memmove/memcpy_P when we know the length of a string to save CPU time. Add tests to inject \0s in a String to ensure it is still working as designed.
cores/esp8266/WString.h
Outdated
enum { SSOSIZE = sizeof(struct _ptr) + 4 - 1 }; // Characters to allocate space for SSO, must be 12 or more | ||
struct _sso { | ||
char buff[SSOSIZE]; | ||
unsigned len : 7; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be unsigned char?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Talking about len or buff? buff
should be char
as that's the non-SSO type. len
is a bitfield so unsigned
or signed
will do the trick.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean unsigned char (1 byte) as opposed to just unsigned (4 bytes)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (after @devyte's review on flag name)
Supercedes #6027
Make SSO more generic by keeping track of its length explicitly,
allowing for embedded \0s to exist in the String (just like the non-SSO
ones).
Use memmove/memcpy_P when we know the length of a string to save CPU
time.
Add tests to inject \0s in a String to ensure it is still working as
designed.