aboutsummaryrefslogtreecommitdiff
path: root/src/ht/ft_htentry_new.c
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-08-02 11:05:33 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-08-02 11:05:33 +0200
commit5d2f925b20ceaea4122c59d2d2c4e7d4ae991fde (patch)
tree80911dc3c32e9f230750e7e1042d413dfb6efab2 /src/ht/ft_htentry_new.c
parentee32953ea79616e72f5428cdf40c834714a891c9 (diff)
parentb96b82194ccad2cddbb46b77aa1962a57c47ff44 (diff)
downloadlibft-5d2f925b20ceaea4122c59d2d2c4e7d4ae991fde.tar.gz
libft-5d2f925b20ceaea4122c59d2d2c4e7d4ae991fde.tar.bz2
libft-5d2f925b20ceaea4122c59d2d2c4e7d4ae991fde.zip
Merge branch 'master' into ft_ssl
Diffstat (limited to 'src/ht/ft_htentry_new.c')
-rw-r--r--src/ht/ft_htentry_new.c37
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);
+}