From 4f138b78e369a141e1c01296082d55f53c53bfe1 Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Tue, 25 Apr 2023 14:31:12 +0000 Subject: [PATCH] clean: remove useless file --- data.h | 22 ++++++++++++++++++++-- philo.h | 20 +++++++++++++++++--- struct.h | 41 ----------------------------------------- 3 files changed, 37 insertions(+), 46 deletions(-) delete mode 100644 struct.h diff --git a/data.h b/data.h index 1f5604c..ffd53be 100644 --- a/data.h +++ b/data.h @@ -1,5 +1,23 @@ -# include "./struct.h" +#ifndef DATA_H +# define DATA_H +# include +# include + +typedef struct s_data +{ + size_t eat_time; + size_t sleep_time; + size_t life_expectency; + size_t nb_philos; + ssize_t nb_meals; + void **philos; + pthread_t *threads; + pthread_mutex_t *forks; + pthread_mutex_t stop_mutex; + bool stop; + pthread_mutex_t print_mutex; +} t_data; bool data_init(t_data *data); void data_destroyer(t_data *data); - +#endif diff --git a/philo.h b/philo.h index 7450b4e..78c0630 100644 --- a/philo.h +++ b/philo.h @@ -6,17 +6,31 @@ /* By: cchauvet +#ifndef PHILO_H +# define PHILO_H +# include # include # include # include # include "./data.h" +typedef struct s_philo +{ + size_t id; + pthread_mutex_t nb_meal_mutex; + size_t nb_meal; + pthread_mutex_t last_eat_mutex; + size_t last_eat; + pthread_mutex_t stop_mutex; + bool stop; + t_data *data; +} t_philo; + t_philo *philo_init(t_data *data); void philo_destroyer(t_philo *philo); void *philo_routine(void *arg); - +#endif diff --git a/struct.h b/struct.h deleted file mode 100644 index f586be4..0000000 --- a/struct.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef STRUCT_H -# define STRUCT_H -# include -# include -# include - -typedef struct s_data -{ - size_t eat_time; - size_t sleep_time; - size_t life_expectency; - size_t nb_philos; - ssize_t nb_meals; - void **philos; - pthread_t *threads; - pthread_mutex_t forks_mutex; - bool *forks; - pthread_mutex_t stop_mutex; - bool stop; - pthread_mutex_t print_mutex; -} t_data; - -typedef struct s_philo -{ - size_t id; - pthread_mutex_t nb_meal_mutex; - size_t nb_meal; - pthread_mutex_t last_eat_mutex; - size_t last_eat; - pthread_mutex_t last_sleep_mutex; - size_t last_sleep; - pthread_mutex_t stop_mutex; - bool stop; - t_data *data; -} t_philo; - -t_philo *philo_create(t_data *data); -t_philo *philo_destoyer(t_philo *philo); -void *philo_routine(void *arg); - -#endif