ajout static, renames, pere fouettard tweaks

This commit is contained in:
Hugo LAMY
2022-01-26 16:31:36 +01:00
parent 6d3280631c
commit 77f2e6b978
9 changed files with 130 additions and 120 deletions

View File

@@ -3,16 +3,16 @@
/* ::: :::::::: */
/* init.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/26 15:30:34 by hulamy #+# #+# */
/* Updated: 2022/01/26 15:30:35 by hulamy ### ########.fr */
/* Updated: 2022/01/26 16:29:38 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
#include "philo.h"
t_philo *lst_add_philo(t_params *params, t_global *global, int i)
static t_philo *lst_add_philo(t_params *params, t_global *global, int i)
{
t_philo *new;
@@ -26,12 +26,12 @@ t_philo *lst_add_philo(t_params *params, t_global *global, int i)
return (NULL);
new->t_last_meal.ts = 0;
new->t_last_meal.tu = 0;
new->eat = 0;
new->eat_count = 0;
new->next = NULL;
return (new);
}
t_philo *init_chain_philo(t_params *params, t_global *global)
static t_philo *init_chain_philo(t_params *params, t_global *global)
{
t_philo *philo;
t_philo *tmp;
@@ -54,7 +54,7 @@ t_philo *init_chain_philo(t_params *params, t_global *global)
return (philo);
}
t_params *init_params(int ac, char **av)
static t_params *init_params(int ac, char **av)
{
t_params *params;
@@ -76,21 +76,19 @@ t_params *init_params(int ac, char **av)
return (params);
}
t_global *init_global(void)
static t_global *init_global(void)
{
t_global *global;
global = malloc(sizeof(t_global));
if (!global)
return (NULL);
global->dead = 0;
global->n_eat = 0;
global->stop = 0;
global->satiated_count = 0;
global->t_start.ts = 0;
global->t_start.tu = 0;
if (pthread_mutex_init(&(global->m_print), NULL) != 0)
return (NULL);
if (pthread_mutex_init(&(global->m_dead), NULL) != 0)
return (NULL);
return (global);
}