To make helgrind errors disappear, delete every mutex shared between
threads only after joining all the threads. This ensures that
no thread can access a mutex after the removal of the mutex because
no thread exists then.
/* By: ljiriste <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/28 09:39:55 by ljiriste #+# #+# */
-/* Updated: 2024/05/09 11:56:50 by ljiriste ### ########.fr */
+/* Updated: 2024/05/09 12:41:33 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
const size_t count = diner->setting.philo_count;
size_t i;
- destroy_mutex(&diner->setting.terminal_lock);
- destroy_mutex(&diner->setting.end_lock);
i = 0;
if (diner->philos)
{
if (diner->forks)
while (i < count)
destroy_mutex(diner->forks + (i++));
+ destroy_mutex(&diner->setting.terminal_lock);
+ destroy_mutex(&diner->setting.end_lock);
free(diner->philos);
free(diner->forks);
free(threads);