Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Strings without null-termination#97

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
aentinger merged 9 commits intomasterfromstringnonull
Jan 25, 2021
Merged
Changes from1 commit
Commits
Show all changes
9 commits
Select commitHold shift + click to select a range
184dd3e
Remove strlen in calls like String::concat(s, strlen(s))
matthijskooijmanMar 16, 2014
59dd995
Make string concat, copy and move work on non-terminated strings
matthijskooijmanMar 16, 2014
81a2d51
Simplify String::concat(char)
matthijskooijmanMar 16, 2014
3b88aca
Make String::concat(const char *, unsigned int) public
matthijskooijmanMar 16, 2014
8431488
Add String(char *, unsigned) constructor
matthijskooijmanMar 16, 2014
dd236bf
Don't mess with the original in String::substring
matthijskooijmanMar 16, 2014
eaab14d
Add String::concat(const uint8_t *, unsigned int) version
matthijskooijmanMar 17, 2014
0d83f1a
Add String(const uint8_t *, unsigned int) constructor
matthijskooijmanAug 4, 2015
d6fd84f
fixup! Make string concat, copy and move work on non-terminated strings
matthijskooijmanDec 31, 2020
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
PrevPrevious commit
NextNext commit
Don't mess with the original in String::substring
Before, substring would (temporarily) add a \0 in the original string atthe end of the substring, so the substring could be copied into a newString object. However, now that the String::copy() method can work withnon-nul-terminated strings (by passing an explicit length), this trickis not needed and we can just call the copy method instead.
  • Loading branch information
@matthijskooijman
matthijskooijman committedJan 25, 2021
commitdd236bfd2c62ed083aaa1b1229d71e85fd92f7a9
5 changes: 1 addition & 4 deletionsapi/String.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -632,10 +632,7 @@ String String::substring(unsigned int left, unsigned int right) const
String out;
if (left >= len) return out;
if (right > len) right = len;
char temp = buffer[right]; // save the replaced character
buffer[right] = '\0';
out = buffer + left; // pointer arithmetic
buffer[right] = temp; //restore character
out.copy(buffer + left, right - left);
return out;
}

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp