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 /include | |
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 'include')
-rw-r--r-- | include/ast.h | 5 | ||||
-rw-r--r-- | include/buffer.h | 7 |
2 files changed, 4 insertions, 8 deletions
diff --git a/include/ast.h b/include/ast.h index b14c26d..ef06257 100644 --- a/include/ast.h +++ b/include/ast.h @@ -43,15 +43,12 @@ struct LhsExpr { }; Ast ast_none(); -void ast_deinit(Ast *ast); -void funcdecl_init(FunctionDecl *self); -void funcdecl_deinit(FunctionDecl *self); +CHECK_RESULT int funcdecl_init(FunctionDecl *self, ScopedAllocator *allocator); CHECK_RESULT int funcdecl_add_to_body(FunctionDecl *self, Ast ast); void funccall_init(FunctionCall *self, BufferView name); void lhsexpr_init(LhsExpr *self, int isConst, BufferView var_name); -void lhsexpr_deinit(LhsExpr *self); #endif diff --git a/include/buffer.h b/include/buffer.h index c45fbde..700ae7b 100644 --- a/include/buffer.h +++ b/include/buffer.h @@ -1,20 +1,19 @@ #ifndef AMALGAM_BUFFER_H #define AMALGAM_BUFFER_H -#include "types.h" -#include "misc.h" +#include "scoped_allocator.h" #define BUFFER_OK 0 #define BUFFER_ALLOC_FAIL -1 typedef struct { + ScopedAllocator *allocator; char* data; usize size; usize capacity; } Buffer; -void buffer_init(Buffer *self); -void buffer_deinit(Buffer *self); +CHECK_RESULT int buffer_init(Buffer *self, ScopedAllocator *allocator, usize initial_capacity); CHECK_RESULT int buffer_append(Buffer *self, void *data, usize size); void* buffer_get(Buffer *self, usize index, usize type_size); |