aboutsummaryrefslogtreecommitdiff
path: root/src/io/ft_printf/utils.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-01-17 10:56:16 +0100
committerCharles <sircharlesaze@gmail.com>2020-01-17 10:56:16 +0100
commitfe37597119353ce183fc404417b81bd4702f64b7 (patch)
treefaa20a8352092c062e2fd272fff2104d9f2ddb3f /src/io/ft_printf/utils.c
parent2e5ca2ab6276b7b24895ade28e1533356ef523dc (diff)
downloadlibft-fe37597119353ce183fc404417b81bd4702f64b7.tar.gz
libft-fe37597119353ce183fc404417b81bd4702f64b7.tar.bz2
libft-fe37597119353ce183fc404417b81bd4702f64b7.zip
Splited include like src/, Adding feature toggle protection in header
Diffstat (limited to 'src/io/ft_printf/utils.c')
-rw-r--r--src/io/ft_printf/utils.c115
1 files changed, 0 insertions, 115 deletions
diff --git a/src/io/ft_printf/utils.c b/src/io/ft_printf/utils.c
deleted file mode 100644
index ad44980..0000000
--- a/src/io/ft_printf/utils.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/* ************************************************************************** */
-/* */
-/* ::: :::::::: */
-/* utils.c :+: :+: :+: */
-/* +:+ +:+ +:+ */
-/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
-/* +#+#+#+#+#+ +#+ */
-/* Created: 2019/10/29 00:12:40 by cacharle #+# #+# */
-/* Updated: 2019/11/13 08:49:58 by cacharle ### ########.fr */
-/* */
-/* ************************************************************************** */
-
-#include "ft_vasprintf.h"
-
-static int nbrlen_radix(long long int nbr, int radix)
-{
- int counter;
- long long unsigned int u_nbr;
-
- if (nbr == 0)
- return (1);
- counter = 0;
- u_nbr = nbr;
- if (nbr < 0)
- {
- counter++;
- u_nbr = -nbr;
- }
- while (u_nbr > 0)
- {
- u_nbr /= radix;
- counter++;
- }
- return (counter);
-}
-
-char *ft_itoa_base(long long int n, char *base)
-{
- char *str;
- int len;
- int radix;
- long long unsigned int u_nbr;
-
- radix = ft_strlen(base);
- len = nbrlen_radix(n, radix);
- if ((str = (char*)malloc(sizeof(char) * (len + 1))) == NULL)
- return (NULL);
- str[len] = '\0';
- u_nbr = n < 0 ? -n : n;
- if (n < 0)
- str[0] = '-';
- while (--len >= (n < 0 ? 1 : 0))
- {
- str[len] = base[u_nbr % radix];
- u_nbr /= radix;
- }
- return (str);
-}
-
-static int nbrlen_unsigned_radix(long long unsigned int nbr, int radix)
-{
- int counter;
-
- if (nbr == 0)
- return (1);
- counter = 0;
- while (nbr > 0)
- {
- nbr /= radix;
- counter++;
- }
- return (counter);
-}
-
-char *ft_itoa_unsigned_base(long long unsigned int n, char *base)
-{
- char *str;
- int len;
- int radix;
-
- radix = ft_strlen(base);
- len = nbrlen_unsigned_radix(n, radix);
- if ((str = (char*)malloc(sizeof(char) * (len + 1))) == NULL)
- return (NULL);
- str[len] = '\0';
- while (--len >= 0)
- {
- str[len] = base[n % radix];
- n /= radix;
- }
- return (str);
-}
-
-void *ft_memjoin_free(void *dst, int dst_size, void *src, int src_size)
-{
- void *clone;
-
- if (dst == NULL)
- {
- if ((dst = malloc(src_size)) == NULL)
- return (NULL);
- ft_memcpy(dst, src, src_size);
- return (dst);
- }
- if ((clone = malloc(dst_size)) == NULL)
- return (NULL);
- ft_memcpy(clone, dst, dst_size);
- free(dst);
- if ((dst = malloc(dst_size + src_size)) == NULL)
- return (NULL);
- ft_memcpy(dst, clone, dst_size);
- free(clone);
- ft_memcpy(dst + dst_size, src, src_size);
- return (dst);
-}