fix structure delete int in s_all on time_t

This commit is contained in:
Matthos Denys 2021-05-12 15:48:43 +03:00
parent fb7985cb67
commit 709288b773
7 changed files with 24 additions and 8 deletions

View File

@ -9,14 +9,21 @@
# include <string.h> # include <string.h>
typedef struct s_all typedef struct s_philo_data
{ {
int number_of_philosophers; pthread_mutex_t *mutex;
int time_to_die; } t_philo_data;
int time_to_eat;
int time_to_sleep;
int number_of_times_each_philosopher_must_eat; typedef struct s_all
} t_all; {
int number_of_philosophers;
time_t time_to_die;
time_t time_to_eat;
time_t time_to_sleep;
int number_of_times_each_philosopher_must_eat;
t_philo_data *data_philo;
} t_all;
void *ft_calloc(size_t num, size_t size); void *ft_calloc(size_t num, size_t size);
t_all *structalloc_and_bzero(void); t_all *structalloc_and_bzero(void);

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -6,6 +6,7 @@ void *test(char *str)
return(NULL); return(NULL);
} }
int func_test(t_all *all) int func_test(t_all *all)
{ {
pthread_t t0; pthread_t t0;
@ -33,11 +34,19 @@ int func_test(t_all *all)
return (0); return (0);
} }
int prepare_resources(t_all *all)
{
all->data_philo = ft_calloc(sizeof(t_philo_data), 1);
all->data_philo->mutex = (pthread_mutex_t *)ft_calloc(sizeof(pthread_mutex_t), all->number_of_philosophers);
}
int runner(t_all *all, int optional) int runner(t_all *all, int optional)
{ {
if (optional) if (optional)
{ {
func_test(all); // func_test(all);
prepare_resources(all);
return(0); return(0);
} }
else else