hardcode ast

This commit is contained in:
Nathan Lebrun
2025-01-27 14:14:02 +01:00
parent 8a24b6817f
commit 775f25a837
7 changed files with 266 additions and 15 deletions

44
tests/tmp_env.c Normal file
View File

@@ -0,0 +1,44 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* tmp_env.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/27 12:35:29 by nalebrun #+# #+# */
/* Updated: 2025/01/27 12:35:29 by nalebrun ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "../lib/libft/libft.h"
static int count_var(char **envp)
{
int i;
i = 0;
if (!envp)
return (-1);
while (envp[i])
i++;
return (i);
}
char **init_env(char **envp)
{
char **env;
int i;
i = 0;
env = malloc(sizeof(char *) * (count_var(envp) + 1));
if (!env)
return (NULL);
env[count_var(envp)] = NULL;
while (envp[i])
{
env[i] = ft_strdup(envp[i]);
i++;
}
return (env);
}