From c98de126d2252fe47dc2a9094a5f9a8fa6b4b60a Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Sun, 11 Oct 2020 15:52:52 +0200 Subject: Removing libft/minishell_test submodules, Removing subject/README/etc --- libft/src/bt/ft_btdestroy.c | 23 +++++++++++++++++++++++ libft/src/bt/ft_btnew.c | 25 +++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 libft/src/bt/ft_btdestroy.c create mode 100644 libft/src/bt/ft_btnew.c (limited to 'libft/src/bt') diff --git a/libft/src/bt/ft_btdestroy.c b/libft/src/bt/ft_btdestroy.c new file mode 100644 index 0000000..c802db0 --- /dev/null +++ b/libft/src/bt/ft_btdestroy.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_btdestroy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/07 21:30:53 by cacharle #+# #+# */ +/* Updated: 2020/02/07 21:35:19 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft_bt.h" + +void ft_btdestroy(t_ftbtree *tree, void (*del)(void *data)) +{ + if (tree == NULL) + return ; + ft_btdestroy(tree->left, del); + ft_btdestroy(tree->right, del); + (*del)(tree->data); + free(tree); +} diff --git a/libft/src/bt/ft_btnew.c b/libft/src/bt/ft_btnew.c new file mode 100644 index 0000000..973e1a4 --- /dev/null +++ b/libft/src/bt/ft_btnew.c @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_btnew.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/07 21:33:16 by cacharle #+# #+# */ +/* Updated: 2020/02/07 21:34:35 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft_bt.h" + +t_ftbtree *ft_btnew(void *data) +{ + t_ftbtree *tree; + + if ((tree = (t_ftbtree*)malloc(sizeof(t_ftbtree))) == NULL) + return (NULL); + tree->data = data; + tree->left = NULL; + tree->right = NULL; + return (tree); +} -- cgit