]> git.dkaiser.de - 42/minishell.git/commitdiff
added remove for env list
authorChristopher Uhlig <chuhlig@1-C-13.42heilbronn.de>
Tue, 17 Sep 2024 14:34:57 +0000 (16:34 +0200)
committerChristopher Uhlig <chuhlig@1-C-13.42heilbronn.de>
Tue, 17 Sep 2024 14:34:57 +0000 (16:34 +0200)
src/builtins_part_one.c

index 42561e922ffbda85f45e2a53c2a86ffac4630540..5a3523661f3c23033fbfe7677f1818e9edbfeadb 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: chuhlig <chuhlig@student.42.fr>            +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2024/08/09 17:01:16 by chuhlig           #+#    #+#             */
-/*   Updated: 2024/09/13 21:46:08 by chuhlig          ###   ########.fr       */
+/*   Updated: 2024/09/17 16:23:15 by chuhlig          ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -155,7 +155,7 @@ int exit(char *av)
 
 //export
 
-int    export(char **av, t_env **env) // here also need to do the same again for envstrarr. dont like it
+int    export(char **av, t_env **env)
 {
        char    *tmp;
        t_env   *current;
@@ -195,7 +195,7 @@ int export(char **av, t_env **env) // here also need to do the same again for en
 
 //unset
 //for unset as well check and for name part
-int    unset(char **av, t_env **env) // here also need to do the same again for envstrarr. dont like it
+int    unset(char **av, t_env **env)
 {
        t_env   *current;
        t_env   *prev;
@@ -243,6 +243,24 @@ void       getenvlst(t_env **env, char **en)// seperated name and value
        return (0);
 }
 
+
+void   free_envlst(t_env **env)
+{
+       t_env   *cur;
+       t_env   *new;
+
+       cur = *env;
+       while (cur)
+       {
+               new = cur->next;
+               free(cur->name);
+               free(cur->value);
+               free(cur);
+               cur = new;
+       }
+       
+}
+
 // void        getenvlststr(t_env **env, char **en)//without serparation
 // {
 //     int                     i;