From af3ee1af961d21f106cf6ccc9606c6043f13d977 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Thu, 20 Jun 2024 17:06:14 +0530 Subject: jobs: use pointer arrays for outputs and dependencies we still get simpler deletions because the order of the array is not important so we can pop the last item and insert it in place of the deleted one --- include/jobs.h | 15 +++++++-------- include/util.h | 7 ------- 2 files changed, 7 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/include/jobs.h b/include/jobs.h index 3a1fb19..d223ec2 100644 --- a/include/jobs.h +++ b/include/jobs.h @@ -3,23 +3,22 @@ #ifndef JOBS_H -LIST_HEAD(output_dlist, output); struct output { char *name, *store_path; - LIST_ENTRY(output) dlist; }; -LIST_HEAD(job_dlist, job); -CIRCLEQ_HEAD(job_clist, job); struct job { char *name, *drv_path; - struct output_dlist outputs; - struct job_dlist deps; - /* TODO: replace dlist with clist jobs.c */ - LIST_ENTRY(job) dlist; + size_t outputs_size, outputs_filled; + struct output **outputs; + + size_t deps_size, deps_filled; + struct job **deps; + CIRCLEQ_ENTRY(job) clist; }; +CIRCLEQ_HEAD(job_clist, job); typedef enum { JOB_READ_SUCCESS = 0, diff --git a/include/util.h b/include/util.h index 5279a07..130bbdd 100644 --- a/include/util.h +++ b/include/util.h @@ -5,13 +5,6 @@ #define print_err(fmt, ...) \ fprintf(stderr, "[%s:%d] " fmt "\n", __FILE__, __LINE__, ##__VA_ARGS__) -#define LIST_FOREACH_FREE(cur, next, head, field, func_free) \ - for ((cur) = ((head)->lh_first); (cur);) { \ - (next) = ((cur)->field.le_next); \ - func_free((cur)); \ - (cur) = (next); \ - } - #define CIRCLEQ_FOREACH_FREE(cur, next, head, field, func_free) \ for ((cur) = ((head)->cqh_first); (cur) != (const void *)(head);) { \ (next) = ((cur)->field.cqe_next); \ -- cgit v1.2.3