aboutsummaryrefslogtreecommitdiff
path: root/src/bt/ft_btnew.c
blob: 09cfa12ba2da5086a52598beca8b099a2c639325 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_btnew.c                                         :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: cacharle <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/02/07 21:33:16 by cacharle          #+#    #+#             */
/*   Updated: 2020/04/26 19:46:57 by charles          ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include "libft_bt.h"

/*
** \brief       Create a new binary tree
** \param data  Node's data
** \return      Allocated node with left and right set to NULL, NULL on error
*/

t_ftbt	*ft_btnew(void *data)
{
	t_ftbt	*tree;

	if ((tree = (t_ftbt*)malloc(sizeof(t_ftbt))) == NULL)
		return (NULL);
	tree->left = NULL;
	tree->right = NULL;
	tree->data = data;
	return (tree);
}