aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
-rw-r--r--src/io/ft_next_line.c12
-rw-r--r--src/lst/ft_lstbsearch.c8
9 files changed, 34 insertions, 14 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);
}
diff --git a/src/io/ft_next_line.c b/src/io/ft_next_line.c
index 59e245b..51d21ec 100644
--- a/src/io/ft_next_line.c
+++ b/src/io/ft_next_line.c
@@ -1,3 +1,15 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_next_line.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/01/31 10:39:38 by cacharle #+# #+# */
+/* Updated: 2020/01/31 10:39:40 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
#include "libft.h"
static int st_find_newline(char *str)
diff --git a/src/lst/ft_lstbsearch.c b/src/lst/ft_lstbsearch.c
index 3d5dbde..25a7b4c 100644
--- a/src/lst/ft_lstbsearch.c
+++ b/src/lst/ft_lstbsearch.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/30 09:17:51 by cacharle #+# #+# */
-/* Updated: 2020/01/30 09:17:53 by cacharle ### ########.fr */
+/* Updated: 2020/01/31 10:42:22 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -26,7 +26,7 @@ static t_ftlst *st_lstmiddle(t_ftlst *lst, t_ftlst *last)
{
fast = fast->next;
if (fast == NULL)
- break;
+ break ;
slow = slow->next;
fast = fast->next;
}
@@ -34,7 +34,7 @@ static t_ftlst *st_lstmiddle(t_ftlst *lst, t_ftlst *last)
}
static t_ftlst *st_lstbsearch_rec(t_ftlst *lst, t_ftlst *last,
- t_ftbool (*equal)(void *ref, void *content), void *ref)
+ t_ftbool (*equal)(void *ref, void *content), void *ref)
{
t_ftlst *mid;
t_ftlst *left;
@@ -50,7 +50,7 @@ static t_ftlst *st_lstbsearch_rec(t_ftlst *lst, t_ftlst *last,
return (st_lstbsearch_rec(mid, NULL, equal, ref));
}
-t_ftlst *ft_lstbsearch(t_ftlst *lst,
+t_ftlst *ft_lstbsearch(t_ftlst *lst,
t_ftbool (*equal)(void *ref, void *content), void *ref)
{
return (st_lstbsearch_rec(lst, NULL, equal, ref));