From 7e85064ac77ea43e84d88eb910b0adb6f07d5d12 Mon Sep 17 00:00:00 2001 From: Randy Palamar Date: Tue, 21 May 2024 10:23:25 -0600 Subject: remove some ui pointer chasing There only exists a single Ui so there is no need to force a pointer redirection for accessing it. The Ui member was moved down in vis-core.h to punt around an issue with the way lua checks for existing objects. It may show up again as I flatten more structs. --- ui-terminal.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'ui-terminal.c') diff --git a/ui-terminal.c b/ui-terminal.c index 048ba7f..d19724a 100644 --- a/ui-terminal.c +++ b/ui-terminal.c @@ -615,20 +615,19 @@ err: return false; } -Ui *ui_terminal_new(void) { +bool ui_terminal_init(Ui *tui) { size_t styles_size = UI_STYLE_MAX * sizeof(CellStyle); CellStyle *styles = calloc(1, styles_size); if (!styles) - return NULL; - Ui *tui = ui_term_backend_new(); - if (!tui) { + return false; + if (!ui_backend_init(tui)) { free(styles); - return NULL; + return false; } tui->styles_size = styles_size; tui->styles = styles; tui->doupdate = true; - return tui; + return true; } void ui_terminal_free(Ui *tui) { @@ -641,5 +640,4 @@ void ui_terminal_free(Ui *tui) { termkey_destroy(tui->termkey); free(tui->cells); free(tui->styles); - free(tui); } -- cgit v1.2.3