/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_next_line_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/01 17:12:02 by adjoly #+# #+# */
/* Updated: 2024/01/10 15:03:07 by adjoly ### ########.fr */
#include "get_next_line.h"
size_t ft_strl_g(char *s)
{
size_t i;
i = 0;
while (s[i])
i++;
return (i);
}
char *ft_strjoin_gnl(char *s1, char *s2)
char *result;
size_t j;
j = 0;
if (!s2)
return (NULL);
result = ft_calloc_gnl((ft_strl_g(s1) + ft_strl_g(s2) + 1), sizeof(char));
if (result == NULL)
while (s1[i])
result[i] = s1[i];
while (s2[j])
result[i] = s2[j];
j++;
free(s1);
result[i] = '\0';
return (result);
void *ft_calloc_gnl(size_t nmemb, size_t size)
if (nmemb == 0 || size == 0)
return (malloc(1));
if (((unsigned long long)(size * nmemb) > 4294967295))
if ((int)size < 0 && (int)nmemb < 0)
result = malloc(size * nmemb);
if (!result)
while (i < (size * nmemb))
*(unsigned char *)(result + i) = '\0';