Join the threads for valgrind not to complain
authorLukas Jiriste <ljiriste@student.42prague.com>
Thu, 9 May 2024 09:06:09 +0000 (11:06 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Thu, 9 May 2024 09:06:09 +0000 (11:06 +0200)
philo/mem_management.c

index a05b5183cb1d650aa9351b6d1de307df001fda7a..aaa9464b5a31614dd1e7629c82839200becf7b80 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: ljiriste <marvin@42.fr>                    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2024/03/28 09:39:55 by ljiriste          #+#    #+#             */
-/*   Updated: 2024/03/28 14:48:46 by ljiriste         ###   ########.fr       */
+/*   Updated: 2024/05/09 11:05:18 by ljiriste         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -60,7 +60,10 @@ void cleanup(t_diner *diner, pthread_t *threads)
        i = 0;
        if (diner->philos)
                while (i < count)
+               {
+                       pthread_join(threads[i], NULL);
                        destroy_mutex(&diner->philos[i++].philo_lock);
+               }
        free(diner->philos);
        free(diner->forks);
        free(threads);