diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-04-01 21:51:51 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-04-01 21:58:05 +0200 |
| commit | 65c5d5157e890e9f9445a94fb2d7f660e5492d8e (patch) | |
| tree | 78613f26bdc531104c3e32d76ffcaf3c2f7013f5 /src/ht/ft_htentry_new.c | |
| parent | c128213daa677d548bfc2905496257fe4a4faf79 (diff) | |
| parent | a1675f56b35f5521a91851bae8ca650706374ae6 (diff) | |
| download | libft-65c5d5157e890e9f9445a94fb2d7f660e5492d8e.tar.gz libft-65c5d5157e890e9f9445a94fb2d7f660e5492d8e.tar.bz2 libft-65c5d5157e890e9f9445a94fb2d7f660e5492d8e.zip | |
Merge branch 'minishell'
Diffstat (limited to 'src/ht/ft_htentry_new.c')
| -rw-r--r-- | src/ht/ft_htentry_new.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/ht/ft_htentry_new.c b/src/ht/ft_htentry_new.c new file mode 100644 index 0000000..12a1159 --- /dev/null +++ b/src/ht/ft_htentry_new.c @@ -0,0 +1,37 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_htentry_new.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/01/30 08:45:36 by cacharle #+# #+# */ +/* Updated: 2020/02/17 04:09:50 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" +#include "libft_ht.h" + +/* +** \brief Create a new hash table key/value pair. +** \param key Hash entry string key (always duplicated) +** \return Content or NULL if an allocation failed. +*/ + +t_ftht_entry *ft_htentry_new(char *key, void *value) +{ + t_ftht_entry *content; + + if (key == NULL) + return (NULL); + if ((content = (t_ftht_entry*)malloc(sizeof(t_ftht_entry))) == NULL) + return (NULL); + if ((content->key = ft_strdup(key)) == NULL) + { + free(content); + return (NULL); + } + content->value = value; + return (content); +} |
