free tous les mallocs

This commit is contained in:
Hugo LAMY
2022-02-02 00:31:51 +01:00
parent 1dc4de3236
commit 5f86d2de1c
7 changed files with 61 additions and 345 deletions

View File

@@ -6,7 +6,7 @@
/* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/26 15:30:34 by hulamy #+# #+# */
/* Updated: 2022/01/31 10:20:25 by hulamy ### ########.fr */
/* Updated: 2022/02/02 00:18:04 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -114,17 +114,20 @@ t_philo *init(int ac, char **av, pthread_t **id)
t_params *params;
t_global *global;
philo = NULL;
params = NULL;
global = NULL;
params = init_params(ac, av);
if (params == NULL)
return (NULL);
global = init_global();
if (params == NULL)
return (NULL);
if (global == NULL)
return (return_free(params, NULL, NULL));
*id = malloc(sizeof(pthread_t) * params->n_phi);
if (*id == NULL)
return (NULL);
return (return_free(params, global, NULL));
philo = init_chain_philo(params, global);
if (philo == NULL)
return (NULL);
return (return_free(params, global, *id));
return (philo);
}