From aba90a3a6f6c1caee28aaf3dadebb4daba5b5761 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sat, 9 Aug 2025 16:06:32 +0300 Subject: use newer conts --- src/clock_domain.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/clock_domain.c') diff --git a/src/clock_domain.c b/src/clock_domain.c index 74f0f03..c1f0450 100644 --- a/src/clock_domain.c +++ b/src/clock_domain.c @@ -12,10 +12,13 @@ #include #include -#include + +#define VEC_NAME components +#define VEC_TYPE struct component * +#include struct clock_domain { - struct vec components; + struct components components; struct clock_time time; tick period; @@ -39,23 +42,24 @@ struct clock_domain *create_clock_domain(tick period) return NULL; clk->period = period; - clk->components = vec_create(sizeof(struct component *)); + clk->components = components_create(0); return clk; } void destroy_clock_domain(struct clock_domain *clk) { - for (size_t i = 0; i < vec_len(&clk->components); ++i) - destroy(vect_at(struct component *, clk->components, i)); + foreach(components, c, &clk->components) { + destroy(*c); + } - vec_destroy(&clk->components); + components_destroy(&clk->components); free(clk); } stat clock_domain_add(struct clock_domain *clk, struct component *component) { - vect_append(struct component *, clk->components, &component); + components_append(&clk->components, component); return OK; } @@ -69,9 +73,8 @@ static void clocked_component_tick(struct clock_domain *clk, stat clock_domain_tick(struct clock_domain *clk) { - for (size_t i = 0; i < vec_len(&clk->components); ++i) { - clocked_component_tick(clk, - vect_at(struct component *, clk->components, i)); + foreach(components, c, &clk->components) { + clocked_component_tick(clk, *c); } advance_clock(clk); -- cgit v1.3