]> git.xolatile.top Git - public-libhl.git/commitdiff
badass memory bug fix
authoranon <anon@anon.anon>
Thu, 24 Aug 2023 19:08:03 +0000 (21:08 +0200)
committeranon <anon@anon.anon>
Thu, 24 Aug 2023 19:09:45 +0000 (21:09 +0200)
source/terminal_hl.h

index 19e6b0ff4b3ea374f6f056886cdde8ebc58f8c9c..c38c0dc24187469c96a4f5d4e188db1363e4e546 100644 (file)
@@ -35,35 +35,29 @@ int terminal_hl_init(void){
        hl_init();
        new_display_mode(cterm);
        //
-       terminal_hl_t terminal_keyword_hl = (terminal_hl_t) {
-               .attribute = TERMINAL_STYLE_BOLD,
-               .foreground_color = TERMINAL_COLOR_FG_GREEN,
-               .background_color = NULL
-       };
-       keyword_hl = &(hl_group_t) {
-               .link = NULL,
-               .attributes = (void*)&terminal_keyword_hl
-       };
+       terminal_hl_t * terminal_keyword_hl = (terminal_hl_t *)malloc(sizeof(terminal_hl_t));
+               terminal_keyword_hl->attribute = TERMINAL_STYLE_BOLD;
+               terminal_keyword_hl->foreground_color = TERMINAL_COLOR_FG_GREEN;;
+               terminal_keyword_hl->background_color = NULL;
+       keyword_hl = (hl_group_t *)malloc(sizeof(hl_group_t));
+               keyword_hl->link = NULL;
+               keyword_hl->attributes = (void*)terminal_keyword_hl;
        //
-       terminal_hl_t terminal_preprocessor_hl = (terminal_hl_t) {
-               .attribute = TERMINAL_STYLE_BOLD,
-               .foreground_color = TERMINAL_COLOR_FG_BLUE,
-               .background_color = NULL
-       };
-       preprocessor_hl = &(hl_group_t) {
-               .link = NULL,
-               .attributes = (void*)&terminal_preprocessor_hl
-       };
+       terminal_hl_t * terminal_preprocessor_hl = (terminal_hl_t *)malloc(sizeof(terminal_hl_t));
+               terminal_preprocessor_hl->attribute = TERMINAL_STYLE_BOLD,
+               terminal_preprocessor_hl->foreground_color = TERMINAL_COLOR_FG_BLUE;
+               terminal_preprocessor_hl->background_color = NULL;
+       preprocessor_hl = (hl_group_t *)malloc(sizeof(hl_group_t));
+               preprocessor_hl->link = NULL;
+               preprocessor_hl->attributes = (void*)terminal_keyword_hl;
        //
-       terminal_hl_t terminal_symbol_hl = (terminal_hl_t) {
-               .attribute = TERMINAL_STYLE_BOLD,
-               .foreground_color = TERMINAL_COLOR_FG_YELLOW,
-               .background_color = NULL
-       };
-       symbol_hl = &(hl_group_t) {
-               .link = NULL,
-               .attributes = (void*)&terminal_symbol_hl
-       };
+       terminal_hl_t * terminal_symbol_hl = (terminal_hl_t *)malloc(sizeof(terminal_hl_t));
+               terminal_symbol_hl->attribute = TERMINAL_STYLE_BOLD;
+               terminal_symbol_hl->foreground_color = TERMINAL_COLOR_FG_YELLOW;
+               terminal_symbol_hl->background_color = NULL;
+       symbol_hl = (hl_group_t *)malloc(sizeof(hl_group_t));
+               symbol_hl->link = NULL;
+               symbol_hl->attributes = (void*)terminal_symbol_hl;
 
        return 0;
 }