intra to gitea

This commit is contained in:
lfirmin
2025-11-16 09:48:49 +01:00
commit 6cea9e2446
82 changed files with 3273 additions and 0 deletions
+67
View File
@@ -0,0 +1,67 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pars.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lfirmin <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/05 08:26:16 by lfirmin #+# #+# */
/* Updated: 2024/11/05 08:26:16 by lfirmin ### ########.fr */
/* */
/* ************************************************************************** */
#include "../include/pushswap.h"
char *init_empty_str(void)
{
char *str;
str = malloc(sizeof(char));
if (!str)
return (NULL);
str[0] = '\0';
return (str);
}
void free_array(char **array)
{
size_t i;
if (!array)
return ;
i = 0;
while (array[i])
{
if (array[i])
free(array[i]);
i++;
}
free(array);
}
char **pars(char **av)
{
char *str;
char **av_pars;
int i;
i = 1;
str = init_empty_str();
if (!str)
return (printf("error\n"), NULL);
while (av[i])
{
str = ft_strcat(str, av[i]);
if (!str)
return (printf("error\n"), NULL);
i++;
}
av_pars = ft_split(str, ' ');
free(str);
if (!av_pars)
{
printf("error\n");
return (NULL);
}
return (av_pars);
}