/* */ /* ::: :::::::: */ /* env2.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: erey-bet +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/02/17 17:22:01 by erey-bet #+# #+# */ /* Updated: 2023/02/17 17:24:57 by erey-bet ### ########.fr */ /* */ /* ************************************************************************** */ #include "env_private.h" int get_index(char *s, char c) { int i; i = -1; while (s[++i]) if (s[i] == c) return (i); return (-1); } void swap_env_3(void **a, void **b, void **c) { void *d; d = *a; *a = *b; *b = *c; *c = d; } void swap_env(void **a, void **b) { void *c; c = *a; *a = *b; *b = c; } void env_del(void *ptr) { t_env *content; if (ptr == NULL) return ; content = ptr; if (content->key != NULL) free(content->key); if (content->key != NULL) free(content->value); if (content != NULL) free(content); } char **env_to_strs(t_list **head) { t_list *current; t_env *content; char **env; int i; current = *head; env = ft_calloc(ft_lstsize(*head), sizeof(char *)); i = 0; while (current->content) { content = current->content; env[i++] = ft_strmerger(3, content->key, "=", content->value); current = current->next; } return (env); }