diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-10-11 15:52:52 +0200 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-10-11 15:52:52 +0200 |
| commit | c98de126d2252fe47dc2a9094a5f9a8fa6b4b60a (patch) | |
| tree | 12f1c827ee063ed3e7038f6a704014e611e4f388 /libft/src/ht/ft_htnew.c | |
| parent | a4ceb5974d1b7dcdd12cc81b7eb07893ea16c8ad (diff) | |
| download | minishell-c98de126d2252fe47dc2a9094a5f9a8fa6b4b60a.tar.gz minishell-c98de126d2252fe47dc2a9094a5f9a8fa6b4b60a.tar.bz2 minishell-c98de126d2252fe47dc2a9094a5f9a8fa6b4b60a.zip | |
Removing libft/minishell_test submodules, Removing subject/README/etc
Diffstat (limited to 'libft/src/ht/ft_htnew.c')
| -rw-r--r-- | libft/src/ht/ft_htnew.c | 37 |
1 files changed, 37 insertions, 0 deletions
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 <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} |
