Remove redirections from the environment
authorLukas Jiriste <ljiriste@student.42prague.com>
Thu, 1 Aug 2024 13:43:26 +0000 (15:43 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Fri, 2 Aug 2024 12:37:34 +0000 (14:37 +0200)
The redirections got handled in another way so this is not needed.

src/env.c
src/execution.c

index 8d6829cb3f22d3c6353adb5695afe9e75e655e3c..236cfdf144141ee355a4b572b8420b681473c92f 100644 (file)
--- a/src/env.c
+++ b/src/env.c
@@ -6,7 +6,7 @@
 /*   By: ljiriste <marvin@42.fr>                    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2024/07/21 21:24:52 by ljiriste          #+#    #+#             */
-/*   Updated: 2024/07/21 23:46:03 by ljiriste         ###   ########.fr       */
+/*   Updated: 2024/08/02 10:46:15 by ljiriste         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -19,14 +19,9 @@ int  init_env(t_execution_env *env, char **envp)
        env->stdin_fd = STDIN_FILENO;
        env->stdout_fd = STDOUT_FILENO;
        env->ret_val = 0;
-       if (ft_vec_init(&env->redirections, sizeof(t_redirection)))
-               return (1);
        env->vars = malloc(sizeof(t_vars));
        if (!env->vars)
-       {
-               ft_vec_free(&env->redirections, NULL);
                return (1);
-       }
        return (init_vars(env->vars, envp));
 }
 
@@ -34,6 +29,5 @@ void  clean_env(t_execution_env *env)
 {
        clean_vars(env->vars);
        free(env->vars);
-       ft_vec_free(&env->redirections, NULL);
        return ;
 }
index c0b835c5a04f0fdbef75e7eca0a9a2405fc5b1fa..0369008d34a0fc709527742bf2c8755294122dd7 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: ljiriste <ljiriste@student.42prague.com>   +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2024/07/21 08:57:54 by ljiriste          #+#    #+#             */
-/*   Updated: 2024/08/01 15:30:29 by ljiriste         ###   ########.fr       */
+/*   Updated: 2024/08/01 15:43:00 by ljiriste         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -814,7 +814,6 @@ int copy_env(t_execution_env *copy, const t_execution_env *env)
        ft_vec_init(&copy->vars->other, sizeof(char *));
        ft_vec_copy(&copy->vars->exported, &env->vars->exported, v_strcopy, free);
        ft_vec_copy(&copy->vars->other, &env->vars->other, v_strcopy, free);
-       ft_vec_copy(&copy->redirections, &env->redirections, v_copy_redir, NULL);
        return (0);
 }
 
@@ -822,7 +821,6 @@ void        free_env(t_execution_env *env)
 {
        clean_vars(env->vars);
        free(env->vars);
-       ft_vec_free(&env->redirections, NULL);
        return ;
 }
 
@@ -900,6 +898,5 @@ int execute(t_tree *parse_tree, t_execution_env *env)
        int     res;
 
        res = ex_program(parse_tree, env);
-       ft_vec_forget_range(&env->redirections, env->redirections.size, 0);
        return (res);
 }