From 4740b89e88dff04361da7f7f3bd9e823fd75d5b2 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Sat, 22 Jun 2024 23:48:45 +0530 Subject: htab: init --- include/htab.h | 18 ++++++++++++++++++ include/jobs.h | 3 ++- include/queue.h | 5 +++-- 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 include/htab.h (limited to 'include') diff --git a/include/htab.h b/include/htab.h new file mode 100644 index 0000000..70a0893 --- /dev/null +++ b/include/htab.h @@ -0,0 +1,18 @@ +#include + +#ifndef HTAB_H + +struct htab { + struct hsearch_data *table; + char **keys; + size_t keys_size, key_filled; +}; + +void htab_free(struct htab *htab); +int htab_init(struct htab **htab); +int htab_delete(struct htab *htab, const char *key); +int htab_enter(struct htab *htab, const char *key, void *data); +int htab_search(struct htab *htab, char *key, ENTRY **ep); + +#define HTAB_H +#endif diff --git a/include/jobs.h b/include/jobs.h index 623eaea..d4916f7 100644 --- a/include/jobs.h +++ b/include/jobs.h @@ -1,5 +1,5 @@ -#include #include +#include #include #ifndef JOBS_H @@ -36,6 +36,7 @@ int job_read(FILE *stream, struct job **jobs); int jobs_init(FILE **stream); void job_free(struct job *j); int job_parents_list_insert(struct job *job, struct job *parent); +void job_deps_list_rm(struct job *job, struct job *dep); #define JOBS_H #endif diff --git a/include/queue.h b/include/queue.h index c454339..4aca54b 100644 --- a/include/queue.h +++ b/include/queue.h @@ -3,6 +3,7 @@ #include #include +#include "htab.h" #include "jobs.h" #ifndef QUEUE_H @@ -14,7 +15,7 @@ typedef enum { struct queue { struct job_clist jobs; - struct hsearch_data *htab; + struct htab *htab; sem_t sem; queue_state_t state; pthread_mutex_t mutex; @@ -29,7 +30,7 @@ struct queue_thread { int queue_thread_new(struct queue_thread **queue_thread, FILE *stream); void queue_thread_free(struct queue_thread *queue_thread); void *queue_thread_entry(void *queue_thread); -int queue_pop(struct queue *queue, struct job **job, struct hsearch_data *htab); +int queue_pop(struct queue *queue, struct job **job, struct htab *htab); #define QUEUE_H #endif -- cgit v1.2.3