refactor: move env_get_size to env_get.c

This commit is contained in:
Jérôme Guélen 2025-02-17 16:52:17 +01:00 committed by Khaïs COLIN
parent 30d32a1d53
commit 622a9caa53
2 changed files with 19 additions and 19 deletions

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* env_get.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jguelen <marvin@42.fr> +#+ +:+ +#+ */
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/14 18:43:38 by jguelen #+# #+# */
/* Updated: 2025/02/18 16:33:10 by khais ### ########.fr */
/* Created: 2025/02/19 12:30/54 by khais #+# #+# */
/* Updated: 2025/02/19 12:30:54 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -81,3 +81,19 @@ char *env_get_val(t_env *env, char *key)
return (node->value);
return (NULL);
}
/*
** Get the number of mappings in the givne env linked list
*/
size_t env_get_size(t_env *env)
{
size_t nb_elem;
nb_elem = 0;
while (env)
{
nb_elem++;
env = env->next;
}
return (nb_elem);
}

View file

@ -60,22 +60,6 @@ void env_destroy(t_env *env)
}
}
/*
** Get the number of mappings in the givne env linked list
*/
size_t env_get_size(t_env *env)
{
size_t nb_elem;
nb_elem = 0;
while (env)
{
nb_elem++;
env = env->next;
}
return (nb_elem);
}
/*
** Find and return a pointer to the node in the given env linked list where the
** key matches the given key.