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/ht/ft_htnew.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 libft/src/ht/ft_htnew.c (limited to 'libft/src/ht/ft_htnew.c') diff --git a/libft/src/ht/ft_htnew.c b/libft/src/ht/ft_htnew.c new file mode 100644 index 0000000..585c211 --- /dev/null +++ b/libft/src/ht/ft_htnew.c @@ -0,0 +1,37 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_htnew.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/01/30 08:19:16 by cacharle #+# #+# */ +/* Updated: 2020/04/04 22:34:55 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft_ht.h" + +/* +** \brief Create a new hash table. +** \param size Size of the underlying array of linked list (buckets) +** \return Created hash table or NULL is an allocation failed +*/ + +t_ftht *ft_htnew(size_t size) +{ + t_ftht *ht; + + if (size == 0) + return (NULL); + if ((ht = (t_ftht*)malloc(sizeof(t_ftht))) == NULL) + return (NULL); + ht->buckets = (t_ftlst**)ft_calloc(size, sizeof(t_ftlst*)); + if (ht->buckets == NULL) + { + free(ht); + return (NULL); + } + ht->size = size; + return (ht); +} -- cgit