32 lines
1.2 KiB
C
32 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: o_ :::::: ::: */
|
|
/* destroy_mutexes.c :+: / :+::+: :+: */
|
|
/* +:+ > +:++:+ +:+ */
|
|
/* By: whaffman <whaffman@student.codam.nl> +#+ +:+ +#++#++:++#++ */
|
|
/* +#+ +#+#+ +#++#+ +#+ \o/ */
|
|
/* Created: 2025/01/20 14:26:46 by whaffman #+#+# #+#+# #+# #+# | */
|
|
/* Updated: 2025/01/20 14:27:38 by whaffman ### ### ### ### / \ */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "philo.h"
|
|
|
|
int destroy_mutexes(t_rules *rules)
|
|
{
|
|
int i;
|
|
|
|
i = 0;
|
|
if (pthread_mutex_destroy(rules->finished_lock))
|
|
return (FAILURE);
|
|
if (pthread_mutex_destroy(rules->print_lock))
|
|
return (FAILURE);
|
|
while (i < rules->n_philos)
|
|
{
|
|
if (pthread_mutex_destroy(&rules->forks[i]))
|
|
return (FAILURE);
|
|
i++;
|
|
}
|
|
return (SUCCESS);
|
|
}
|