diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-02-24 17:53:46 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-25 14:36:46 +0200 |
commit | a27a3e6ae09e8396584c95a3567b145e86d8bc40 (patch) | |
tree | 6b56721fb64f31e4b731e75942f81838d10b0612 /src/parser.c | |
parent | a307f17f44b461f58441926fcbf87883f17ebe61 (diff) |
Fixed CHECK_RESULT macro, use scoped allocator
Scoped allocator gives us better performance and cleanup code for error
cases is much cleaner
Diffstat (limited to 'src/parser.c')
-rw-r--r-- | src/parser.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/parser.c b/src/parser.c index 875c0bc..6a1c796 100644 --- a/src/parser.c +++ b/src/parser.c @@ -7,17 +7,12 @@ static CHECK_RESULT int parser_parse_body(Parser *self, Ast *ast); int parser_init(Parser *self) { - buffer_init(&self->ast_objects); return_if_error(scoped_allocator_init(&self->allocator)); + return_if_error(buffer_init(&self->ast_objects, &self->allocator, sizeof(Ast) * 8)); return PARSER_OK; } void parser_deinit(Parser *self) { - usize i; - for(i = 0; i < self->ast_objects.size / sizeof(Ast); ++i) { - ast_deinit((Ast*)&self->ast_objects.data[i]); - } - buffer_deinit(&self->ast_objects); scoped_allocator_deinit(&self->allocator); } @@ -62,7 +57,7 @@ static CHECK_RESULT int parser_parse_function_decl(Parser *self, FunctionDecl ** return_if_error(tokenizer_accept(&self->tokenizer, TOK_OPEN_BRACE)); return_if_error(scoped_allocator_alloc(&self->allocator, sizeof(FunctionDecl), (void**)func_decl)); - funcdecl_init(*func_decl); + cleanup_if_error(funcdecl_init(*func_decl, &self->allocator)); for(;;) { Ast body_obj; |