From 3a9d944f7485fca92557f9d5415ce1e88ecf8d4e Mon Sep 17 00:00:00 2001 From: Etienne Rey-bethbeder Date: Sat, 25 Mar 2023 04:07:47 +0100 Subject: [PATCH] Help --- mandatory/threads.c | 11 +++++++---- utils/ft_itoa.c | 17 +++++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/mandatory/threads.c b/mandatory/threads.c index 2dc61e2..7abb702 100644 --- a/mandatory/threads.c +++ b/mandatory/threads.c @@ -6,7 +6,7 @@ /* By: erey-bet +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/03/08 20:08:33 by erey-bet #+# #+# */ -/* Updated: 2023/03/24 16:38:39 by erey-bet ### ########.fr */ +/* Updated: 2023/03/25 00:17:08 by erey-bet ### ########.fr */ /* */ /* ************************************************************************** */ @@ -40,7 +40,7 @@ void message(int id, char *msg) all = ft_calloc(ft_strlen(id_str) + ft_strlen(msg) + ft_strlen(time) + 1, 1); i = -1; while (time[++i]) - all[i] = id_str[i]; + all[i] = time[i]; while (id_str[++i - ft_strlen(time)]) all[i] = id_str[i - ft_strlen(time)]; while (msg[++i - ft_strlen(time) - ft_strlen(id_str)]) @@ -170,7 +170,10 @@ t_philo *init_philo(t_same *same, t_only *only) int manage_threads(t_config *config) { - pthread_t *threads; + (void)config; + message(1, "testfuck\n"); + return (0); + /*pthread_t *threads; t_same *same; int i; @@ -196,5 +199,5 @@ int manage_threads(t_config *config) } } destroy_mutex(same->mutex, 3); - return (0); + return (0);*/ } diff --git a/utils/ft_itoa.c b/utils/ft_itoa.c index c47acdf..f418a8d 100644 --- a/utils/ft_itoa.c +++ b/utils/ft_itoa.c @@ -19,11 +19,20 @@ char *ft_itoa(long long n) long long i; q = 10; - while (n / q > 0) - q = q * 10; - str = malloc(sizeof(char) * q + 1); i = 0; - while (q > 0) + while (n / q > 0) + { + q = q * 10; + i++; + } + str = malloc(sizeof(char) * i + 1); + if (!str) + return (NULL); + i = 0; + while (q > 1) + {; str[i++] = (n / q % 10) + 48; + q = q / 10; + } return (str); }