From bedf525dcb893ab6aacd44f000151e43cc285f50 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Tue, 29 Mar 2022 14:02:02 -0400 Subject: [PATCH] Patch some bits of calc.c for new stringObj() --- src/calc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/calc.c b/src/calc.c index c73d932..20bccff 100644 --- a/src/calc.c +++ b/src/calc.c @@ -213,14 +213,13 @@ static void add_token() // Calculate result, display it and reset static void calculate() { - char temp[RESULT_LENGTH + 2] = ""; - trim(excess_chars); excess_chars = 0; Object obj = parseEval(displayed_code, &env); updateText(); - stringNObj(temp, &obj, RESULT_LENGTH); + size_t length; + char* temp = stringObj(&obj, &length); if (obj.type == TYPE_ERROR) { text_layer_set_font(s_result_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD)); @@ -229,6 +228,7 @@ static void calculate() fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); } snprintf(result_text, RESULT_LENGTH, RESULT_PREFIX "%s", temp); + free(temp); text_layer_set_text(s_result_text_layer, result_text); } @@ -470,7 +470,9 @@ static void custom_load(Window* window) Object add_window(Object obj1, Object _, struct Environment* env) { printf("ADD_WINDOW\n"); - stringObj(header, &obj1); + size_t length; + char* temp = stringObj(&obj1, &length); + sprintf(header, "%s", temp); if (!s_custom_window) { s_custom_window = window_create();