diff options
author | koekeishiya <aasvi93@hotmail.com> | 2018-05-10 14:12:02 +0200 |
---|---|---|
committer | koekeishiya <aasvi93@hotmail.com> | 2018-05-10 14:12:02 +0200 |
commit | d7f5fd5730ca252c2635efd263ba40282a31ca57 (patch) | |
tree | 8ec37ab3427ff4848a86f58f8785f5641416b1ca /src/parse.c | |
parent | 1343e122d8fcbeba0c9d588263a7325fce552547 (diff) | |
download | skhd-d7f5fd5730ca252c2635efd263ba40282a31ca57.tar.gz skhd-d7f5fd5730ca252c2635efd263ba40282a31ca57.zip |
replace const sized array with dynamic array for handling modes
Diffstat (limited to 'src/parse.c')
-rw-r--r-- | src/parse.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/parse.c b/src/parse.c index 3e60dd1..d219d8c 100644 --- a/src/parse.c +++ b/src/parse.c @@ -184,7 +184,7 @@ parse_mode(struct parser *parser, struct hotkey *hotkey) return; } - hotkey->mode_list[hotkey->mode_count++] = mode; + buf_push(hotkey->mode_list, mode); printf("\tmode: '%s'\n", mode->name); if (parser_match(parser, Token_Comma)) { @@ -212,13 +212,13 @@ parse_hotkey(struct parser *parser) } } - if (hotkey->mode_count > 0) { + if (buf_len(hotkey->mode_list) > 0) { if (!parser_match(parser, Token_Insert)) { parser_report_error(parser, Error_Unexpected_Token, "expected '<'"); goto err; } } else { - hotkey->mode_list[hotkey->mode_count++] = find_or_init_default_mode(parser); + buf_push(hotkey->mode_list, find_or_init_default_mode(parser)); } if ((found_modifier = parser_match(parser, Token_Modifier))) { @@ -330,7 +330,7 @@ void parse_config(struct parser *parser) (parser_check(parser, Token_Key_Hex)) || (parser_check(parser, Token_Key))) { if ((hotkey = parse_hotkey(parser))) { - for (int i = 0; i < hotkey->mode_count; ++i) { + for (int i = 0; i < buf_len(hotkey->mode_list); ++i) { mode = hotkey->mode_list[i]; table_add(&mode->hotkey_map, hotkey, hotkey); } |