aboutsummaryrefslogtreecommitdiffstats
path: root/src/bytecode/chunk.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bytecode/chunk.c')
-rw-r--r--src/bytecode/chunk.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/bytecode/chunk.c b/src/bytecode/chunk.c
index 3dc2421..8b87d0d 100644
--- a/src/bytecode/chunk.c
+++ b/src/bytecode/chunk.c
@@ -2,11 +2,13 @@
2#include "objects.h" 2#include "objects.h"
3 3
4Chunk * 4Chunk *
5chunk_init(void) { 5chunk_init(StringView name) {
6 Chunk *chunk = malloc(sizeof(Chunk)); 6 Chunk *chunk = malloc(sizeof(Chunk));
7 array_init(chunk->code, 0); 7 array_init(chunk->code, 0);
8 array_init(chunk->constants, 0); 8 array_init(chunk->constants, 0);
9 array_init(chunk->lines, 0); 9 array_init(chunk->lines, 0);
10 array_init(chunk->name, name.n);
11 array_insert(chunk->name, name.start, name.n);
10 return chunk; 12 return chunk;
11} 13}
12 14
@@ -19,6 +21,7 @@ chunk_free(Chunk *chunk) {
19 } 21 }
20 array_free(chunk->constants); 22 array_free(chunk->constants);
21 array_free(chunk->lines); 23 array_free(chunk->lines);
24 array_free(chunk->name);
22 free(chunk); 25 free(chunk);
23} 26}
24 27