Skip to content

Commit 439ded5

Browse files
committed
Allocate tokens using the new arena allocator
1 parent eafcbc5 commit 439ded5

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/token.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "include/token.h"
2+
#include "include/util/hb_arena.h"
23
#include "include/lexer.h"
34
#include "include/position.h"
45
#include "include/range.h"
@@ -14,7 +15,7 @@ size_t token_sizeof(void) {
1415
}
1516

1617
token_T* token_init(const char* value, const token_type_T type, lexer_T* lexer) {
17-
token_T* token = calloc(1, token_sizeof());
18+
token_T* token = hb_arena_alloc(lexer->allocator, token_sizeof());
1819

1920
if (type == TOKEN_NEWLINE) {
2021
lexer->current_line++;
@@ -155,6 +156,4 @@ void token_free(token_T* token) {
155156
if (!token) { return; }
156157

157158
if (token->value != NULL) { free(token->value); }
158-
159-
free(token);
160159
}

0 commit comments

Comments
 (0)