#include "philo.h"

int	create_mutexes(t_rules *rules)
{
	int	i;

	i = 0;
	printf("creating mutexes\n");
	if (pthread_mutex_init(rules->death_lock, NULL))
		return(printf("death mutex created"), FAILURE);
	if (pthread_mutex_init(rules->print_lock, NULL))
		return(printf("print mutex created"), FAILURE);
	printf("creating forks\n");
	rules->forks = malloc(rules->n_philos * sizeof(pthread_mutex_t));
	if	(!rules->forks)
		return(FAILURE);
	while (i < rules->n_philos)
	{
		if (pthread_mutex_init(&rules->forks[i], NULL))
			return(FAILURE);
		i++;
	}
	return (SUCCESS);
}