From fd75b689281e235ebd6b7c84d2557805af789e2d Mon Sep 17 00:00:00 2001 From: objnull Date: Mon, 9 Sep 2024 07:34:13 -0400 Subject: [PATCH] Code Cleanup --- project/ui/app.h | 1 - project/ui/scenes/auth.c | 8 ++++---- project/ui/scenes/create.c | 8 +++++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/project/ui/app.h b/project/ui/app.h index 3b1bb84..ce45a2d 100644 --- a/project/ui/app.h +++ b/project/ui/app.h @@ -56,7 +56,6 @@ typedef struct { void* usb_prev_mode; Manager* manager; - char* enterkey; char* keyboard; int selection; } FP_App; diff --git a/project/ui/scenes/auth.c b/project/ui/scenes/auth.c index 89eac36..21f66ab 100644 --- a/project/ui/scenes/auth.c +++ b/project/ui/scenes/auth.c @@ -10,10 +10,10 @@ void FP_Scene_Callback_Auth(void* context) { FP_App* app = context; // Loading manager with key - app->manager = manager_init(app->enterkey); + app->manager = manager_init(app->keyboard); // Freeing key - free(app->enterkey); + free(app->keyboard); // Going to main menu! scene_manager_next_scene(app->scene_manager, FP_Scene_MainMenu); @@ -26,7 +26,7 @@ void FP_Scene_Enter_Auth(void* context) { text_input_reset(app->textinput); // Creating keyboard string - app->enterkey = malloc(sizeof(char) * KEYBOARD_STR_LEN); + app->keyboard = malloc(sizeof(char) * KEYBOARD_STR_LEN); // Setting stuff text_input_set_header_text( @@ -37,7 +37,7 @@ void FP_Scene_Enter_Auth(void* context) { app->textinput, FP_Scene_Callback_Auth, app, - app->enterkey, + app->keyboard, KEYBOARD_STR_LEN, true ); diff --git a/project/ui/scenes/create.c b/project/ui/scenes/create.c index 34409c3..ef341e3 100644 --- a/project/ui/scenes/create.c +++ b/project/ui/scenes/create.c @@ -115,8 +115,14 @@ bool FP_Scene_Event_Create(void* context, SceneManagerEvent event) { // Set selection app->selection = event.event; + // Checking if our keyboard already has existing data + if (app->keyboard) { + free(app->keyboard); + } + // Setting the title - app->keyboard = malloc(sizeof(char*)); + app->keyboard = malloc(sizeof(char*) * KEYBOARD_STR_LEN); + switch(app->selection){ case 0: app->keyboard = "Name";