diff --git a/Makefile b/Makefile index 29a7523..bb789be 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,5 @@ SRCS = parsing.c \ utils/ft_isnum.c \ - utils/putchar.c \ - utils/putnum.c \ - utils/putstr.c \ utils/ft_atoi.c \ main.c \ time.c \ diff --git a/print.c b/print.c index 5cee2ab..7eb190a 100644 --- a/print.c +++ b/print.c @@ -6,7 +6,7 @@ /* By: cchauvet print_mutex); } diff --git a/print2.c b/print2.c index 7691378..f597e66 100644 --- a/print2.c +++ b/print2.c @@ -6,7 +6,7 @@ /* By: cchauvet data; time = get_time(); pthread_mutex_lock(&data->print_mutex); - ft_putnum(time, 7); - ft_putchar(' '); - ft_putnum(philo->id + 1, 3); - ft_putchar(' '); - ft_putstr("died"); - ft_putchar('\n'); + printf("%7zu %3zu %s\n", time, philo->id, "died"); pthread_mutex_unlock(&data->print_mutex); } diff --git a/utils/putchar.c b/utils/putchar.c deleted file mode 100644 index 0c0fdb6..0000000 --- a/utils/putchar.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* putchar.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cchauvet - -void ft_putchar(char c) -{ - write(1, &c, 1); -} diff --git a/utils/putchar.o b/utils/putchar.o new file mode 100644 index 0000000..6dc697c Binary files /dev/null and b/utils/putchar.o differ diff --git a/utils/putnum.c b/utils/putnum.c deleted file mode 100644 index e63b5be..0000000 --- a/utils/putnum.c +++ /dev/null @@ -1,59 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* putnum.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cchauvet -#include -#include -#include "utils.h" - -static size_t get_size(size_t num) -{ - size_t nb_digit; - size_t rest; - - nb_digit = 0; - if (num == 0) - nb_digit++; - rest = num; - while (rest != 0) - { - nb_digit++; - rest = rest / 10; - } - return (nb_digit); -} - -static void ft_putdigit(size_t num) -{ - if (num > 9) - { - ft_putdigit(num / 10); - ft_putchar(num % 10 + 48); - } - else - ft_putchar(num + 48); -} - -void ft_putnum(size_t num, size_t padding) -{ - size_t size; - size_t i; - - i = 0; - size = get_size(num); - while (i < padding - size) - { - ft_putchar('0'); - i++; - } - ft_putdigit(num); -} diff --git a/utils/putnum.o b/utils/putnum.o new file mode 100644 index 0000000..fc7a7af Binary files /dev/null and b/utils/putnum.o differ diff --git a/utils/putstr.c b/utils/putstr.c deleted file mode 100644 index ffc9796..0000000 --- a/utils/putstr.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* putstr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cchauvet - -void ft_putstr(char *str) -{ - size_t i; - - i = 0; - while (str[i] != 0) - { - ft_putchar(str[i]); - i++; - } -} diff --git a/utils/putstr.o b/utils/putstr.o new file mode 100644 index 0000000..262d5fb Binary files /dev/null and b/utils/putstr.o differ