From 01b4cc91d1596cf94d709a627ed8ad64bc1e285d Mon Sep 17 00:00:00 2001 From: Charles Date: Sun, 16 Feb 2020 04:51:41 +0100 Subject: Filled lst* tests --- src/ht/ft_htdelone.c | 4 ++-- src/ht/ft_htget.c | 4 ++-- src/ht/ft_inter_htkey_cmp.c | 21 +++++++++++++++++++++ src/ht/ft_inter_htkey_equal.c | 21 --------------------- 4 files changed, 25 insertions(+), 25 deletions(-) create mode 100644 src/ht/ft_inter_htkey_cmp.c delete mode 100644 src/ht/ft_inter_htkey_equal.c (limited to 'src/ht') diff --git a/src/ht/ft_htdelone.c b/src/ht/ft_htdelone.c index d502bf2..e4ab80f 100644 --- a/src/ht/ft_htdelone.c +++ b/src/ht/ft_htdelone.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/30 09:27:18 by cacharle #+# #+# */ -/* Updated: 2020/01/31 10:40:40 by cacharle ### ########.fr */ +/* Updated: 2020/02/16 02:20:35 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,6 +16,6 @@ void ft_htdelone(t_ftht *ht, char *key, void (*del)(t_ftht_content*)) { ft_lstremove_if(ht->entries + ft_hthash(ht, key), - (t_ftbool (*)(void*, void*))ft_inter_htkey_equal, key, + ft_inter_htkey_equal, key, (void (*)(void*))del); } diff --git a/src/ht/ft_htget.c b/src/ht/ft_htget.c index 02ce4a3..6a9d785 100644 --- a/src/ht/ft_htget.c +++ b/src/ht/ft_htget.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/30 08:33:21 by cacharle #+# #+# */ -/* Updated: 2020/02/14 02:18:00 by cacharle ### ########.fr */ +/* Updated: 2020/02/16 02:23:23 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -23,6 +23,6 @@ void *ft_htget(t_ftht *ht, char *key) return (NULL); digest = ft_hthash(ht, key); return (((t_ftht_content*)ft_lstbsearch(ht->entries[digest], - (t_ftbool (*)(void*, void*))ft_inter_htkey_equal, + ft_inter_htkey_equal, key)->content)->value); } diff --git a/src/ht/ft_inter_htkey_cmp.c b/src/ht/ft_inter_htkey_cmp.c new file mode 100644 index 0000000..c91663d --- /dev/null +++ b/src/ht/ft_inter_htkey_cmp.c @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_internal_htkey_equal.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/01/30 09:24:39 by cacharle #+# #+# */ +/* Updated: 2020/02/16 02:25:43 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" +#include "libft_ht.h" + +int ft_inter_htkey_cmp(const void *ref_key, const void *content) +{ + if (ref_key == NULL || content == NULL) + return (-1); + return (ft_strcmp((char*)ref_key, ((t_ftht_content*)content)->key)); +} diff --git a/src/ht/ft_inter_htkey_equal.c b/src/ht/ft_inter_htkey_equal.c deleted file mode 100644 index 7714c84..0000000 --- a/src/ht/ft_inter_htkey_equal.c +++ /dev/null @@ -1,21 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_internal_htkey_equal.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/01/30 09:24:39 by cacharle #+# #+# */ -/* 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); -} -- cgit