2021-05-16 14:48:43 +03:00

54 lines
821 B
C

#include "../includes/philo_header.h"
t_all *structalloc_and_bzero(void)
{
t_all *all;
all = ft_calloc(sizeof(t_all), 1);
all->number_of_philosophers = -1;
all->time_to_die = -1;
all->time_to_eat = -1;
all->time_to_sleep = -1;
all->number_of_times_each_philosopher_must_eat = -1;
return(all);
}
int return_big(int a, int b)
{
if (a > b)
{
return (a);
}
return (b);
}
int return_less(int a, int b)
{
if (a < b)
{
return (a);
}
return (b);
}
void ft_exit(t_all *all)
{
int i;
i = 0;
all->smert = 42;
ft_msleep(200);
while (i <= all->number_of_philosophers)
{
pthread_mutex_destroy(&all->data_philo->philors[i].eat_mutex);
pthread_mutex_destroy(&all->data_philo->mutex[i]);
i++;
}
i = 0;
while (i < all->number_of_philosophers)
{
free(&all->data_philo->philors[i]);
i++;
}
}