Make the code adhere to the Norm
authorLukas Jiriste <ljiriste@student.42prague.com>
Thu, 26 Sep 2024 08:36:03 +0000 (10:36 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Thu, 26 Sep 2024 08:36:03 +0000 (10:36 +0200)
philo/philo.c

index a2fd35403dbc31b8d9046614d0de74142c0c0d23..b8541c82c5fd6b3a1158102dbb36ed767ff9c23a 100644 (file)
@@ -19,11 +19,12 @@ static void philo_think(t_philo *philo)
        return ;
 }
 
-static void    take_forks(t_philo *philo)
+// The integer inputs are only there to save me a few lines in the
+// function body
+// This is precisely why I despise how the Norm is written
+// This is much worse solution but it passes norminette
+static void    take_forks(t_philo *philo, int i, int forks_taken)
 {
-       int     i;
-       int     forks_taken;
-
        i = 0;
        forks_taken = 0;
        while (forks_taken < 2 && !end(philo->settings))
@@ -52,7 +53,7 @@ static void   take_forks(t_philo *philo)
 
 static void    philo_eat(t_philo *philo)
 {
-       take_forks(philo);
+       take_forks(philo, 0, 0);
        report(philo, "has taken a fork");
        report(philo, "has taken a fork");
        mutex_lock(&philo->philo_lock);