From 6df9e8bf9433cb095090dab0474367b220585a47 Mon Sep 17 00:00:00 2001 From: Johnny Richard Date: Mon, 24 Apr 2023 23:52:03 +0200 Subject: util: Implement dynamic vector array for storing AST children Previously, we lacked a dynamic array for storing children elements in our abstract syntax tree (AST). This commit introduces a new implementation that dynamically adjusts its capacity as elements are added, using a doubling strategy. I considered two approaches for managing the vector's memory allocation: allocating it on the heap, or providing a vector_init function that allocates only the items array. Ultimately, I decided to provide a vector_new function for instantiating the vector, as this aligns with the expected usage pattern when there is a destroy function. With this new implementation, we can efficiently store and manage AST children, enabling more flexible and expressive tree structures. Signed-off-by: Johnny Richard --- test/Makefile | 3 +++ 1 file changed, 3 insertions(+) (limited to 'test/Makefile') diff --git a/test/Makefile b/test/Makefile index 1858166..09adcfb 100644 --- a/test/Makefile +++ b/test/Makefile @@ -17,6 +17,9 @@ clean: string_view_test: munit.o ../build/string_view.o string_view_test.o $(CC) $? $(CFLAGS) -o $@ +vector_test: munit.o ../build/vector.o vector_test.o + $(CC) $? $(CFLAGS) -o $@ + lexer_test: munit.o ../build/string_view.o ../build/lexer.o lexer_test.o $(CC) $? $(CFLAGS) -o $@ -- cgit v1.2.3