aoc-2019-c

git clone https://git.sinitax.com/sinitax/aoc-2019-c
Log | Files | Refs | README | sfeed.txt

commit 657f00f7306825c6f5f5554aab842af3ae72b9eb
parent 939efe346da5dab0844f54d4dfad0d06a3582528
Author: Louis Burda <quent.burda@gmail.com>
Date:   Fri, 17 Mar 2023 21:28:41 +0100

Switch to liballoc versions

Diffstat:
M02/info.mk | 2+-
M02/main.c | 3++-
M05/info.mk | 2+-
M06/main.c | 3++-
M07/info.mk | 2+-
M07/main.c | 5+++--
MMakefile | 7++++---
Mcommon/icc.c | 4+++-
8 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/02/info.mk b/02/info.mk @@ -1,3 +1,3 @@ 02_SRC = 02/main.c common/main.c common/aoc.c common/icc.c common/util.c -02_SRC += lib/libdvec/build/libdvec.a +02_SRC += lib/libdvec/build/libdvec.a lib/liballoc/build/liballoc.a 02_HDR = common/aoc.h common/icc.h common/util.h diff --git a/02/main.c b/02/main.c @@ -1,6 +1,7 @@ #include "aoc.h" #include "icc.h" #include "util.h" +#include "allocator.h" #include <stdlib.h> #include <stdio.h> @@ -41,7 +42,7 @@ part2(void) icc.abort_on_err = false; icc_parse_inst(&icc, aoc.input, aoc.input_size); - dvec_init(&inst, sizeof(int), 0); + dvec_init(&inst, sizeof(int), 0, &stdlib_heap_allocator); dvec_copy(&inst, &icc.instructions); icc_debug_dump(&icc, &inst); diff --git a/05/info.mk b/05/info.mk @@ -1,3 +1,3 @@ 05_SRC = 05/main.c common/main.c common/icc.c common/aoc.c common/util.c -05_SRC += lib/libdvec/build/libdvec.a +05_SRC += lib/libdvec/build/libdvec.a lib/liballoc/build/liballoc.a 05_HDR = common/aoc.h common/icc.h common/util.h diff --git a/06/main.c b/06/main.c @@ -38,7 +38,8 @@ add_planet(const char *name) p->name = aprintf("%s", name); p->parent = NULL; - dvec_init(&p->children, sizeof(struct planet *), 3); + dvec_init(&p->children, sizeof(struct planet *), + 3, &stdlib_heap_allocator); hashmap_set(&planets, aprintf("%s", name), strlen(name), p, sizeof(struct planet)); diff --git a/07/info.mk b/07/info.mk @@ -1,3 +1,3 @@ 07_SRC = 07/main.c common/main.c common/icc.c common/aoc.c common/util.c -07_SRC += lib/libdvec/build/libdvec.a +07_SRC += lib/libdvec/build/libdvec.a lib/liballoc/build/liballoc.a 07_HDR = common/aoc.h common/icc.h common/util.h diff --git a/07/main.c b/07/main.c @@ -1,3 +1,4 @@ +#include "allocator.h" #include "aoc.h" #include "icc.h" #include "util.h" @@ -145,7 +146,7 @@ part1(void) icc_init(&icc); icc_parse_inst(&icc, aoc.input, aoc.input_size); - dvec_init(&inst, 1, 0); + dvec_init(&inst, 1, 0, &stdlib_heap_allocator); dvec_copy(&inst, &icc.instructions); max = 0; @@ -171,7 +172,7 @@ part2(void) icc_init(&iccs[0]); icc_parse_inst(&iccs[0], aoc.input, aoc.input_size); - dvec_init(&inst, 1, 0); + dvec_init(&inst, 1, 0, &stdlib_heap_allocator); dvec_copy(&inst, &iccs[0].instructions); for (i = 1; i < 5; i++) { diff --git a/Makefile b/Makefile @@ -8,9 +8,6 @@ all:: include */info.mk -lib/liballoc/build/liballoc.a: - make -C lib/liballoc build/liballoc.a DEBUG=1 - lib/libdvec/build/libdvec.a: make -C lib/libdvec build/libdvec.a DEBUG=1 @@ -20,6 +17,9 @@ lib/libhashmap/build/libhashmap.a: lib/libmaxint/build/libmaxint.a: make -C lib/libmaxint build/libmaxint.a DEBUG=1 +lib/liballoc/build/liballoc.a: + make -C lib/liballoc build/liballoc.a DEBUG=1 + define make-day all:: $1/main run:: $1/run @@ -41,5 +41,6 @@ cleanall: clean make -C lib/libdvec clean make -C lib/libhashmap clean make -C lib/libmaxint clean + make -C lib/liballoc clean .PHONY: all clean cleanall diff --git a/common/icc.c b/common/icc.c @@ -1,4 +1,5 @@ #include "icc.h" +#include "allocator.h" #include "aoc.h" #include "util.h" #include "dvec.h" @@ -31,7 +32,8 @@ icc_init(struct icc *icc) icc->line_terminated = true; - rc = dvec_init(&icc->instructions, sizeof(int), 0); + rc = dvec_init(&icc->instructions, + sizeof(int), 0, &stdlib_heap_allocator); assert(!rc); }