From aa9613efb6fb39bd96fc4836b5d38c3746af1b15 Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 30 Jan 2020 10:36:49 +0100 Subject: hash table draft --- src/ht/ft_htcontent_new.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/ht/ft_htcontent_new.c (limited to 'src/ht/ft_htcontent_new.c') diff --git a/src/ht/ft_htcontent_new.c b/src/ht/ft_htcontent_new.c new file mode 100644 index 0000000..4ffa9bf --- /dev/null +++ b/src/ht/ft_htcontent_new.c @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_htcontent_new.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/01/30 08:45:36 by cacharle #+# #+# */ +/* Updated: 2020/01/30 09:52:28 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" +#include "libft_ht.h" + +t_ftht_content *ft_htcontent_new(char *key, void *value) +{ + t_ftht_content *content; + + if (key == NULL) + return (NULL); + if ((content = (t_ftht_content*)malloc(sizeof(t_ftht_content))) == NULL) + return (NULL); + if ((content->key = ft_strdup(key)) == NULL) + { + free(content); + return (NULL); + } + content->value = value; + return (content); +} -- cgit