projects
/
babeltrace.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use objstack for AST allocation
[babeltrace.git]
/
formats
/
ctf
/
metadata
/
ctf-parser.y
diff --git
a/formats/ctf/metadata/ctf-parser.y
b/formats/ctf/metadata/ctf-parser.y
index 1a57922b65b289c4ab24138a65857ca4aeef9212..f4c61f33d2fd733b29118f6a17ee436d29889e37 100644
(file)
--- a/
formats/ctf/metadata/ctf-parser.y
+++ b/
formats/ctf/metadata/ctf-parser.y
@@
-953,14
+953,13
@@
do { \
YYERROR; \
} while (0)
YYERROR; \
} while (0)
-static struct ctf_ast *ctf_ast_alloc(
void
)
+static struct ctf_ast *ctf_ast_alloc(
struct ctf_scanner *scanner
)
{
struct ctf_ast *ast;
{
struct ctf_ast *ast;
- ast =
malloc(
sizeof(*ast));
+ ast =
objstack_alloc(scanner->objstack,
sizeof(*ast));
if (!ast)
return NULL;
if (!ast)
return NULL;
- memset(ast, 0, sizeof(*ast));
ast->root.type = NODE_ROOT;
BT_INIT_LIST_HEAD(&ast->root.tmp_head);
BT_INIT_LIST_HEAD(&ast->root.u.root.declaration_list);
ast->root.type = NODE_ROOT;
BT_INIT_LIST_HEAD(&ast->root.tmp_head);
BT_INIT_LIST_HEAD(&ast->root.u.root.declaration_list);
@@
-973,11
+972,6
@@
static struct ctf_ast *ctf_ast_alloc(void)
return ast;
}
return ast;
}
-static void ctf_ast_free(struct ctf_ast *ast)
-{
- free(ast);
-}
-
int ctf_scanner_append_ast(struct ctf_scanner *scanner)
{
return yyparse(scanner);
int ctf_scanner_append_ast(struct ctf_scanner *scanner)
{
return yyparse(scanner);
@@
-1003,12
+997,12
@@
struct ctf_scanner *ctf_scanner_alloc(FILE *input)
/* Start processing new stream */
yyrestart(input, scanner->scanner);
/* Start processing new stream */
yyrestart(input, scanner->scanner);
- scanner->ast = ctf_ast_alloc();
- if (!scanner->ast)
- goto cleanup_lexer;
scanner->objstack = objstack_create();
if (!scanner->objstack)
scanner->objstack = objstack_create();
if (!scanner->objstack)
- goto cleanup_ast;
+ goto cleanup_lexer;
+ scanner->ast = ctf_ast_alloc(scanner);
+ if (!scanner->ast)
+ goto cleanup_objstack;
init_scope(&scanner->root_scope, NULL);
scanner->cs = &scanner->root_scope;
init_scope(&scanner->root_scope, NULL);
scanner->cs = &scanner->root_scope;
@@
-1019,8
+1013,8
@@
struct ctf_scanner *ctf_scanner_alloc(FILE *input)
return scanner;
return scanner;
-cleanup_
ast
:
-
ctf_ast_free(scanner->ast
);
+cleanup_
objstack
:
+
objstack_destroy(scanner->objstack
);
cleanup_lexer:
ret = yylex_destroy(scanner->scanner);
if (!ret)
cleanup_lexer:
ret = yylex_destroy(scanner->scanner);
if (!ret)
@@
-1036,7
+1030,6
@@
void ctf_scanner_free(struct ctf_scanner *scanner)
finalize_scope(&scanner->root_scope);
objstack_destroy(scanner->objstack);
finalize_scope(&scanner->root_scope);
objstack_destroy(scanner->objstack);
- ctf_ast_free(scanner->ast);
ret = yylex_destroy(scanner->scanner);
if (ret)
printf_error("yylex_destroy error");
ret = yylex_destroy(scanner->scanner);
if (ret)
printf_error("yylex_destroy error");
This page took
0.024752 seconds
and
4
git commands to generate.