Error management on write for bonus part

This commit is contained in:
David Gailleton
2025-11-21 15:57:06 +01:00
parent 620054c92e
commit 3b9f024c3c
9 changed files with 81 additions and 35 deletions

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/17 12:19:16 by dgaillet #+# #+# */
/* Updated: 2025/11/21 14:18:06 by dgaillet ### ########lyon.fr */
/* Updated: 2025/11/21 15:46:51 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
@@ -22,10 +22,12 @@ int print_pointer(t_arg *arg, unsigned long long p)
if (!p)
{
count += print_chars(arg->padding - 5, ' ');
ft_putstr_fd("(nil)", 1);
return (5);
if (write(1, "(nil)", 5) < 0)
return (-10000);
return (5 + count);
}
count += print_chars(arg->padding - nbr_size_base(p, 16) - 2, ' ');
count += write(1, "0x", 2);
return (count + ft_putnbr_base_ll(p, "0123456789abcdef", 16));
if (write(1, "0x", 2) < 0)
return (-10000);
return (count + 2 + ft_putnbr_base_ll(p, "0123456789abcdef", 16));
}