mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 11:30:30 +00:00
lib: parser: fix allocation counting
command_lex.l was allocating as MTYPE_TMP, while command_parse.y would just call free(). Make both use MTYPE_LEX. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
parent
26df3a33ae
commit
55b7f20fda
@ -59,13 +59,13 @@ RANGE \({NUMBER}[ ]?\-[ ]?{NUMBER}\)
|
|||||||
%}
|
%}
|
||||||
|
|
||||||
[ \t]+ LOC_STEP /* ignore whitespace */;
|
[ \t]+ LOC_STEP /* ignore whitespace */;
|
||||||
{WORD} {yylval->string = XSTRDUP(MTYPE_TMP, yytext); return WORD;}
|
{WORD} {yylval->string = XSTRDUP(MTYPE_LEX, yytext); return WORD;}
|
||||||
{IPV4} {yylval->string = XSTRDUP(MTYPE_TMP, yytext); return IPV4;}
|
{IPV4} {yylval->string = XSTRDUP(MTYPE_LEX, yytext); return IPV4;}
|
||||||
{IPV4_PREFIX} {yylval->string = XSTRDUP(MTYPE_TMP, yytext); return IPV4_PREFIX;}
|
{IPV4_PREFIX} {yylval->string = XSTRDUP(MTYPE_LEX, yytext); return IPV4_PREFIX;}
|
||||||
{IPV6} {yylval->string = XSTRDUP(MTYPE_TMP, yytext); return IPV6;}
|
{IPV6} {yylval->string = XSTRDUP(MTYPE_LEX, yytext); return IPV6;}
|
||||||
{IPV6_PREFIX} {yylval->string = XSTRDUP(MTYPE_TMP, yytext); return IPV6_PREFIX;}
|
{IPV6_PREFIX} {yylval->string = XSTRDUP(MTYPE_LEX, yytext); return IPV6_PREFIX;}
|
||||||
{VARIABLE} {yylval->string = XSTRDUP(MTYPE_TMP, yytext); return VARIABLE;}
|
{VARIABLE} {yylval->string = XSTRDUP(MTYPE_LEX, yytext); return VARIABLE;}
|
||||||
{RANGE} {yylval->string = XSTRDUP(MTYPE_TMP, yytext); return RANGE;}
|
{RANGE} {yylval->string = XSTRDUP(MTYPE_LEX, yytext); return RANGE;}
|
||||||
. {return yytext[0];}
|
. {return yytext[0];}
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
@ -46,10 +46,13 @@
|
|||||||
%code requires {
|
%code requires {
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
#include "memory.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "graph.h"
|
#include "graph.h"
|
||||||
|
|
||||||
|
DECLARE_MTYPE(LEX)
|
||||||
|
|
||||||
#define YYSTYPE CMD_YYSTYPE
|
#define YYSTYPE CMD_YYSTYPE
|
||||||
#define YYLTYPE CMD_YYLTYPE
|
#define YYLTYPE CMD_YYLTYPE
|
||||||
struct parser_ctx;
|
struct parser_ctx;
|
||||||
@ -216,7 +219,7 @@ simple_token:
|
|||||||
literal_token: WORD
|
literal_token: WORD
|
||||||
{
|
{
|
||||||
$$ = new_token_node (ctx, WORD_TKN, $1, doc_next(ctx));
|
$$ = new_token_node (ctx, WORD_TKN, $1, doc_next(ctx));
|
||||||
free ($1);
|
XFREE (MTYPE_LEX, $1);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -224,27 +227,27 @@ placeholder_token:
|
|||||||
IPV4
|
IPV4
|
||||||
{
|
{
|
||||||
$$ = new_token_node (ctx, IPV4_TKN, $1, doc_next(ctx));
|
$$ = new_token_node (ctx, IPV4_TKN, $1, doc_next(ctx));
|
||||||
free ($1);
|
XFREE (MTYPE_LEX, $1);
|
||||||
}
|
}
|
||||||
| IPV4_PREFIX
|
| IPV4_PREFIX
|
||||||
{
|
{
|
||||||
$$ = new_token_node (ctx, IPV4_PREFIX_TKN, $1, doc_next(ctx));
|
$$ = new_token_node (ctx, IPV4_PREFIX_TKN, $1, doc_next(ctx));
|
||||||
free ($1);
|
XFREE (MTYPE_LEX, $1);
|
||||||
}
|
}
|
||||||
| IPV6
|
| IPV6
|
||||||
{
|
{
|
||||||
$$ = new_token_node (ctx, IPV6_TKN, $1, doc_next(ctx));
|
$$ = new_token_node (ctx, IPV6_TKN, $1, doc_next(ctx));
|
||||||
free ($1);
|
XFREE (MTYPE_LEX, $1);
|
||||||
}
|
}
|
||||||
| IPV6_PREFIX
|
| IPV6_PREFIX
|
||||||
{
|
{
|
||||||
$$ = new_token_node (ctx, IPV6_PREFIX_TKN, $1, doc_next(ctx));
|
$$ = new_token_node (ctx, IPV6_PREFIX_TKN, $1, doc_next(ctx));
|
||||||
free ($1);
|
XFREE (MTYPE_LEX, $1);
|
||||||
}
|
}
|
||||||
| VARIABLE
|
| VARIABLE
|
||||||
{
|
{
|
||||||
$$ = new_token_node (ctx, VARIABLE_TKN, $1, doc_next(ctx));
|
$$ = new_token_node (ctx, VARIABLE_TKN, $1, doc_next(ctx));
|
||||||
free ($1);
|
XFREE (MTYPE_LEX, $1);
|
||||||
}
|
}
|
||||||
| RANGE
|
| RANGE
|
||||||
{
|
{
|
||||||
@ -260,7 +263,7 @@ placeholder_token:
|
|||||||
// validate range
|
// validate range
|
||||||
if (token->min > token->max) cmd_yyerror (&@1, ctx, "Invalid range.");
|
if (token->min > token->max) cmd_yyerror (&@1, ctx, "Invalid range.");
|
||||||
|
|
||||||
free ($1);
|
XFREE (MTYPE_LEX, $1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* <selector|set> productions */
|
/* <selector|set> productions */
|
||||||
@ -332,6 +335,8 @@ selector: '[' selector_seq_seq ']'
|
|||||||
|
|
||||||
#undef scanner
|
#undef scanner
|
||||||
|
|
||||||
|
DEFINE_MTYPE(LIB, LEX, "Lexer token (temporary)")
|
||||||
|
|
||||||
void
|
void
|
||||||
command_parse_format (struct graph *graph, struct cmd_element *cmd)
|
command_parse_format (struct graph *graph, struct cmd_element *cmd)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user