Some changes
This commit is contained in:
@@ -49,8 +49,9 @@ void init_editor(TextEditor *editor, BitmapFont *font, int x, int y, SDL_Rendere
|
||||
}
|
||||
|
||||
// Allocate output and display strings.
|
||||
editor->outputString = (char *) malloc(sizeof(char) * (editor->max_line_width * editor->maxLines + 1));
|
||||
editor->displayString = (char *) malloc(sizeof(char) * (editor->max_line_width * editor->displayLineCount + 1));
|
||||
editor->outputString = (char *) malloc(sizeof(char) * ((editor->max_line_width + 1) * editor->maxLines + 1) + 1);
|
||||
editor->displayString = (char *) malloc(
|
||||
sizeof(char) * ((editor->max_line_width + 1) * editor->displayLineCount + 1) + 1);
|
||||
if (!editor->outputString || !editor->displayString) {
|
||||
fprintf(stderr, "Failed to allocate memory for output/display strings.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
@@ -301,9 +302,9 @@ void generate_string_display(TextEditor *editor, SDL_Renderer *renderer) {
|
||||
charDstRect.x += charDstRect.w + 1;
|
||||
linePTR++;
|
||||
}
|
||||
strcat(editor->displayString, "\n");
|
||||
charDstRect.x = 4;
|
||||
charDstRect.y += charDstRect.h + 1;
|
||||
strcat(editor->displayString, "\n");
|
||||
}
|
||||
}
|
||||
SDL_SetRenderTarget(renderer, NULL);
|
||||
|
Reference in New Issue
Block a user