Fixed a bug on zero padding the string's byte content.
This commit is contained in:
@@ -110,9 +110,8 @@ void TStringRemoveRange(int startIndex, int count, TString* string) {
|
||||
|
||||
for (glyphCount = 0; glyphCount < count; glyphCount++) endByte += GetGlyphByteWidth(string->Characters[endByte]);
|
||||
|
||||
memset(&string->Characters[startByte], '\0', endByte - startByte);
|
||||
|
||||
if (endByte == string->ByteCount) {
|
||||
memset(&string->Characters[startByte], '\0', endByte - startByte);
|
||||
string->Length -= glyphCount;
|
||||
string->ByteCount -= endByte - startByte;
|
||||
return;
|
||||
@@ -120,7 +119,7 @@ void TStringRemoveRange(int startIndex, int count, TString* string) {
|
||||
|
||||
unsigned int fullBuffers = (string->ByteCount - endByte) / sizeof buffer;
|
||||
unsigned int remainder = (string->ByteCount - endByte) - fullBuffers * sizeof buffer;
|
||||
|
||||
|
||||
for (int i = fullBuffers; i > 0; i--) {
|
||||
memcpy(buffer, &string->Characters[string->ByteCount - i * sizeof buffer], sizeof buffer);
|
||||
memcpy(&string->Characters[endByte - sizeof buffer * i], buffer, sizeof buffer);
|
||||
@@ -131,7 +130,7 @@ void TStringRemoveRange(int startIndex, int count, TString* string) {
|
||||
memcpy(&string->Characters[startByte], buffer, remainder);
|
||||
}
|
||||
|
||||
memset(&string->Characters[endByte], '\0', string->ByteCount - endByte);
|
||||
memset(&string->Characters[string->ByteCount - endByte - startByte], '\0', endByte - startByte);
|
||||
|
||||
string->Length -= glyphCount;
|
||||
string->ByteCount -= endByte - startByte;
|
||||
|
||||
Reference in New Issue
Block a user