aboutsummaryrefslogtreecommitdiff
path: root/src/ht
diff options
context:
space:
mode:
Diffstat (limited to 'src/ht')
-rw-r--r--src/ht/ft_htdelone.c2
-rw-r--r--src/ht/ft_htdestroy_all.c4
-rw-r--r--src/ht/ft_htdestroy_key.c2
-rw-r--r--src/ht/ft_htget.c4
-rw-r--r--src/ht/ft_htnew.c9
-rw-r--r--src/ht/ft_htset.c2
-rw-r--r--src/ht/ft_inter_htkey_equal.c5
7 files changed, 18 insertions, 10 deletions
diff --git a/src/ht/ft_htdelone.c b/src/ht/ft_htdelone.c
index b376d8b..d502bf2 100644
--- a/src/ht/ft_htdelone.c
+++ b/src/ht/ft_htdelone.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/30 09:27:18 by cacharle #+# #+# */
-/* Updated: 2020/01/30 09:55:06 by cacharle ### ########.fr */
+/* Updated: 2020/01/31 10:40:40 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
diff --git a/src/ht/ft_htdestroy_all.c b/src/ht/ft_htdestroy_all.c
index ec54044..6f98a43 100644
--- a/src/ht/ft_htdestroy_all.c
+++ b/src/ht/ft_htdestroy_all.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/30 08:29:58 by cacharle #+# #+# */
-/* Updated: 2020/01/30 08:30:53 by cacharle ### ########.fr */
+/* Updated: 2020/01/31 10:43:13 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -20,7 +20,7 @@ static void st_htdelcontent_all(t_ftht_content *content)
free(content->value);
}
-void ft_htdestroy_all(t_ftht *ht)
+void ft_htdestroy_all(t_ftht *ht)
{
ft_htdestroy(ht, *st_htdelcontent_all);
}
diff --git a/src/ht/ft_htdestroy_key.c b/src/ht/ft_htdestroy_key.c
index 1cae2fd..a704314 100644
--- a/src/ht/ft_htdestroy_key.c
+++ b/src/ht/ft_htdestroy_key.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/30 08:31:02 by cacharle #+# #+# */
-/* Updated: 2020/01/30 09:46:14 by cacharle ### ########.fr */
+/* Updated: 2020/01/31 10:43:45 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
diff --git a/src/ht/ft_htget.c b/src/ht/ft_htget.c
index b4715a3..0002249 100644
--- a/src/ht/ft_htget.c
+++ b/src/ht/ft_htget.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/30 08:33:21 by cacharle #+# #+# */
-/* Updated: 2020/01/30 09:25:51 by cacharle ### ########.fr */
+/* Updated: 2020/01/31 10:40:57 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,8 +15,10 @@
t_ftht_content *ft_htget(t_ftht *ht, char *key)
{
+
t_ftht_digest digest;
+ return (NULL); // lstbsearch breaking
if (ht == NULL || key == NULL)
return (NULL);
digest = ft_hthash(ht, key);
diff --git a/src/ht/ft_htnew.c b/src/ht/ft_htnew.c
index bcf81d1..950a4fe 100644
--- a/src/ht/ft_htnew.c
+++ b/src/ht/ft_htnew.c
@@ -6,20 +6,25 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/30 08:19:16 by cacharle #+# #+# */
-/* Updated: 2020/01/30 08:19:18 by cacharle ### ########.fr */
+/* Updated: 2020/01/31 10:41:57 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include "libft_ht.h"
+#define FT_HT_MAX_SIZE (1 << 14)
+
t_ftht *ft_htnew(t_ftsize size)
{
t_ftht *ht;
+ if (size == 0 || size > FT_HT_MAX_SIZE)
+ return (NULL);
if ((ht = (t_ftht*)malloc(sizeof(t_ftht))) == NULL)
return (NULL);
- if ((ht->entries = (t_ftht_entry*)ft_calloc(size, sizeof(t_ftht_entry))) == NULL)
+ ht->entries = (t_ftht_entry*)ft_calloc(size, sizeof(t_ftht_entry));
+ if (ht->entries == NULL)
{
free(ht);
return (NULL);
diff --git a/src/ht/ft_htset.c b/src/ht/ft_htset.c
index 86e9690..5ace788 100644
--- a/src/ht/ft_htset.c
+++ b/src/ht/ft_htset.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/30 08:41:52 by cacharle #+# #+# */
-/* Updated: 2020/01/30 08:50:48 by cacharle ### ########.fr */
+/* Updated: 2020/01/31 10:33:39 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
diff --git a/src/ht/ft_inter_htkey_equal.c b/src/ht/ft_inter_htkey_equal.c
index b652bba..7714c84 100644
--- a/src/ht/ft_inter_htkey_equal.c
+++ b/src/ht/ft_inter_htkey_equal.c
@@ -6,15 +6,16 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/30 09:24:39 by cacharle #+# #+# */
-/* Updated: 2020/01/30 09:25:36 by cacharle ### ########.fr */
+/* Updated: 2020/01/31 09:51:03 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
+#include "libft_ht.h"
t_ftbool ft_inter_htkey_equal(char *ref_key, t_ftht_content *content)
{
if (ref_key == NULL || content == NULL)
return (FALSE);
- return (ft_strcmp(ref_key, content->key) == 0)
+ return (ft_strcmp(ref_key, content->key) == 0);
}