diff options
author | Laurent Fasnacht <fasnacht@protonmail.ch> | 2020-02-10 10:17:24 +0000 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2020-02-13 13:03:15 +0100 |
commit | ad63cde708fd7a79332b09ae4a06b8a4b345aa72 (patch) | |
tree | 9b4c12bfb0fbd7d6bc52c34ee26db56617d8aa77 /src | |
parent | 35adaa2741414551ffbc3970cb2dd1704cce1179 (diff) |
scanner: remove parser_state->indescs static array
This static array is redundant with the indesc_list structure, but
is less flexible.
Signed-off-by: Laurent Fasnacht <fasnacht@protonmail.ch>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/scanner.l | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/scanner.l b/src/scanner.l index ecf2354e..e982cd41 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -668,19 +668,20 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr}) static void scanner_push_indesc(struct parser_state *state, struct input_descriptor *indesc) { - state->indescs[state->indesc_idx] = indesc; - state->indesc = state->indescs[state->indesc_idx++]; list_add_tail(&indesc->list, &state->indesc_list); + state->indesc = indesc; + state->indesc_idx++; } static void scanner_pop_indesc(struct parser_state *state) { state->indesc_idx--; - - if (state->indesc_idx > 0) - state->indesc = state->indescs[state->indesc_idx - 1]; - else + if (!list_empty(&state->indesc_list)) { + state->indesc = list_entry(state->indesc->list.prev, + struct input_descriptor, list); + } else { state->indesc = NULL; + } } static void scanner_pop_buffer(yyscan_t scanner) |