1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 17:58:12 +00:00

StringView: Rename characters() to characters_without_null_termination().

This should make you think twice before trying to use the const char* from
a StringView as if it's a null-terminated string.
This commit is contained in:
Andreas Kling 2019-07-08 15:38:44 +02:00
parent 567551bc12
commit 0e75aba7c3
21 changed files with 57 additions and 46 deletions

View file

@ -127,7 +127,7 @@ RefPtr<Font> Font::load_from_file(const StringView& path)
bool Font::write_to_file(const StringView& path)
{
int fd = creat(path.characters(), 0644);
int fd = creat(String(path).characters(), 0644);
if (fd < 0) {
perror("open");
return false;
@ -169,7 +169,7 @@ int Font::width(const StringView& string) const
int width = 0;
for (int i = 0; i < string.length(); ++i)
width += glyph_width(string.characters()[i]) + 1;
width += glyph_width(string.characters_without_null_termination()[i]) + 1;
return width - 1;
}