Fixed some of the range delete bugs. There still seems to be a bug when the remainder is one however.

This commit is contained in:
2022-07-08 15:48:43 +00:00
parent cc4e2b3ad0
commit d8821e64de
2 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ int ReadAllString(const char* path, char** content_ptr, size_t* bytes_read) {
}
char *content = NULL, *temp;
size_t used = 0, capacity = 0, read = 0; //Allows initialize stack allocated values to zero!
size_t used = 0, capacity = 0, read = 0; //Always initialize stack allocated values to zero!
while(1) {
if (used + FUTIL_READ_SIZE + 1 > capacity) {
+4 -3
View File
@@ -128,15 +128,16 @@ void TStringRemoveRange(int startIndex, int count, TString* string) {
}
if (remainder > 0) {
memset(buffer, 0, sizeof buffer);
memcpy(buffer, &string->Characters[string->ByteCount - remainder], remainder);
printf("Buffer: %s\n", buffer);
memcpy(&string->Characters[startByte + fullBuffers * sizeof buffer], buffer, remainder);
}
memset(&string->Characters[string->ByteCount - endByte - startByte], '\0', endByte - startByte);
string->Length -= glyphCount;
string->ByteCount -= endByte - startByte;
string->ByteCount -= endByte - startByte;
memset(&string->Characters[string->ByteCount], '\0', string->Capacity - string->ByteCount);
}
void TStringInsertText(const char* text, int index, TString* string) {