From 8131a5d26441c5152ab151b4bb49b561e5ca6e81 Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 31 Jan 2020 10:44:30 +0100 Subject: hash table unit testing, norming --- include/libft_ctype.h | 2 +- include/libft_ht.h | 2 +- include/libft_io.h | 2 +- include/libft_lst.h | 2 +- include/libft_mem.h | 2 +- include/libft_str.h | 2 +- include/libft_types.h | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/libft_ctype.h b/include/libft_ctype.h index ad42c64..61f4534 100644 --- a/include/libft_ctype.h +++ b/include/libft_ctype.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:35:31 by cacharle #+# #+# */ -/* Updated: 2020/02/10 05:18:30 by cacharle ### ########.fr */ +/* Updated: 2020/02/28 12:08:52 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/include/libft_ht.h b/include/libft_ht.h index 62f2ee1..5a764b6 100644 --- a/include/libft_ht.h +++ b/include/libft_ht.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:36:09 by cacharle #+# #+# */ -/* Updated: 2020/02/19 02:38:28 by cacharle ### ########.fr */ +/* Updated: 2020/02/28 12:18:19 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/include/libft_io.h b/include/libft_io.h index 76bce17..418b230 100644 --- a/include/libft_io.h +++ b/include/libft_io.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:35:43 by cacharle #+# #+# */ -/* Updated: 2020/02/14 02:23:43 by cacharle ### ########.fr */ +/* Updated: 2020/02/28 12:09:11 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/include/libft_lst.h b/include/libft_lst.h index a48c1aa..2b4321c 100644 --- a/include/libft_lst.h +++ b/include/libft_lst.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:36:39 by cacharle #+# #+# */ -/* Updated: 2020/02/17 03:05:36 by cacharle ### ########.fr */ +/* Updated: 2020/02/28 12:09:21 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/include/libft_mem.h b/include/libft_mem.h index a15c020..37c072e 100644 --- a/include/libft_mem.h +++ b/include/libft_mem.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:35:57 by cacharle #+# #+# */ -/* Updated: 2020/02/13 03:11:09 by cacharle ### ########.fr */ +/* Updated: 2020/02/28 12:17:48 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/include/libft_str.h b/include/libft_str.h index 582ef00..ad04966 100644 --- a/include/libft_str.h +++ b/include/libft_str.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:39:22 by cacharle #+# #+# */ -/* Updated: 2020/02/14 03:45:15 by cacharle ### ########.fr */ +/* Updated: 2020/02/28 12:09:56 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/include/libft_types.h b/include/libft_types.h index 20fe0f7..3987a80 100644 --- a/include/libft_types.h +++ b/include/libft_types.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:36:56 by cacharle #+# #+# */ -/* Updated: 2020/02/13 03:07:56 by cacharle ### ########.fr */ +/* Updated: 2020/02/28 12:10:02 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ -- cgit From 915f1b888cf9c05e4b61321f84ac045eacd8ddd1 Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 27 Feb 2020 18:07:57 +0100 Subject: Added ft_lstlfind,ft_lstlsearch and ft_split_destroy --- include/libft_lst.h | 2 +- include/libft_util.h | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 include/libft_util.h (limited to 'include') diff --git a/include/libft_lst.h b/include/libft_lst.h index 2b4321c..5669979 100644 --- a/include/libft_lst.h +++ b/include/libft_lst.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:36:39 by cacharle #+# #+# */ -/* Updated: 2020/02/28 12:09:21 by cacharle ### ########.fr */ +/* Updated: 2020/02/28 12:23:31 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/include/libft_util.h b/include/libft_util.h new file mode 100644 index 0000000..7a9e056 --- /dev/null +++ b/include/libft_util.h @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft_util.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/27 17:51:36 by cacharle #+# #+# */ +/* Updated: 2020/02/27 17:52:16 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_UTIL_H +# define LIBFT_UTIL_H + +# include + +void *ft_split_destroy(char **strs); + +#endif -- cgit From e792d0a3ff1c1da456c241530571263df0b887b5 Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 4 Mar 2020 16:19:05 +0100 Subject: Added ft_htiter.c --- include/libft_ht.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/libft_ht.h b/include/libft_ht.h index 5a764b6..ea6cb3f 100644 --- a/include/libft_ht.h +++ b/include/libft_ht.h @@ -45,6 +45,7 @@ void ft_htdelone(t_ftht *ht, char *key, void (*del)(t_ftht_content*)); void ft_htdelone_key(t_ftht *ht, char *key); t_ftht_content *ft_htcontent_new(char *key, void *value); +void ft_htiter(t_ftht *ht, void (*f)(t_ftht_content*)); /* ** internals -- cgit From c128213daa677d548bfc2905496257fe4a4faf79 Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 11 Mar 2020 21:07:32 +0100 Subject: ft_mem* and ft_strlen optimization --- include/libft_mem.h | 1 + include/libft_str.h | 1 + 2 files changed, 2 insertions(+) (limited to 'include') diff --git a/include/libft_mem.h b/include/libft_mem.h index a15c020..fb52760 100644 --- a/include/libft_mem.h +++ b/include/libft_mem.h @@ -14,6 +14,7 @@ # define LIBFT_MEM_H # include +# include # include "libft_types.h" void ft_bzero(void *s, size_t n); diff --git a/include/libft_str.h b/include/libft_str.h index 582ef00..1f665b5 100644 --- a/include/libft_str.h +++ b/include/libft_str.h @@ -15,6 +15,7 @@ # include # include "libft_ctype.h" +# include "libft_mem.h" typedef enum { -- cgit From 8bba48a8326d9e7a703c3f6f6ab70b8a8a393473 Mon Sep 17 00:00:00 2001 From: Charles Date: Sat, 28 Mar 2020 12:07:44 +0100 Subject: Added ft_strjoin3 --- include/libft_str.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/libft_str.h b/include/libft_str.h index ad04966..ea6115d 100644 --- a/include/libft_str.h +++ b/include/libft_str.h @@ -52,6 +52,7 @@ void ft_striter(char *s, void (*f)(char *)); void ft_striteri(char *s, void (*f)(unsigned int, char *)); char *ft_substr(char const *s, unsigned int start, size_t len); char *ft_strjoin(char const *s1, char const *s2); +char *ft_strjoin3(char const *s1, char const *s2, char const *s3); char *ft_strjoinf(char const *s1, char const *s2, t_ftstrjoinf_tag tag); char *ft_strtrim(char const *s1, char const *set); char **ft_split(char const *s, char c); -- cgit From 901402c99018422c994bdb297e3ba404969c88ea Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 30 Mar 2020 22:26:36 +0200 Subject: Added documentation for ht and lst --- include/libft_ht.h | 41 +++++++++++++++++++++++++++-------------- include/libft_lst.h | 25 ++++++++++++++++++------- 2 files changed, 45 insertions(+), 21 deletions(-) (limited to 'include') diff --git a/include/libft_ht.h b/include/libft_ht.h index ea6cb3f..24abf95 100644 --- a/include/libft_ht.h +++ b/include/libft_ht.h @@ -13,21 +13,38 @@ #ifndef LIBFT_HT_H # define LIBFT_HT_H +/** +** \file libft_ht.h +** \brief Hash table manipulation +*/ + # include "libft.h" # include "libft_lst.h" -typedef struct s_ftht_content +/** +** \brief Hash table entry, key/value pair +** \param key String key +** \param value Pointer to data +*/ + +typedef struct s_ftht_entry { char *key; void *value; -} t_ftht_content; +} t_ftht_entry; + +typedef t_ftlst* t_ftht_bucket; -typedef t_ftlst* t_ftht_entry; +/** +** \brief Hash table struct +** \param size Number of buckets +** \param buckets Bucket array +*/ typedef struct s_ftht { t_ftsize size; - t_ftht_entry *entries; + t_ftht_bucket *buckets; } t_ftht; typedef t_ftuint t_ftht_digest; @@ -35,23 +52,19 @@ typedef t_ftuint t_ftht_digest; t_ftht_digest ft_hthash(t_ftht *ht, char *key); t_ftht *ft_htnew(t_ftsize size); -void ft_htdestroy(t_ftht *ht, void (*del)(t_ftht_content*)); -void ft_htdestroy_all(t_ftht *ht); -void ft_htdestroy_key(t_ftht *ht); +void ft_htdestroy(t_ftht *ht, void (*del)(t_ftht_entry*)); void *ft_htget(t_ftht *ht, char *key); -t_ftht_content *ft_htset(t_ftht *ht, char *key, void *value, - void (*del)(t_ftht_content*)); +t_ftht_entry *ft_htset(t_ftht *ht, char *key, void *value, + void (*del)(t_ftht_entry*)); void ft_htdelone(t_ftht *ht, char *key, - void (*del)(t_ftht_content*)); -void ft_htdelone_key(t_ftht *ht, char *key); -t_ftht_content *ft_htcontent_new(char *key, void *value); -void ft_htiter(t_ftht *ht, void (*f)(t_ftht_content*)); + void (*del)(t_ftht_entry*)); +t_ftht_entry *ft_htentry_new(char *key, void *value); +void ft_htiter(t_ftht *ht, void (*f)(t_ftht_entry*)); /* ** internals */ -void ft_inter_htdelcontent_key(t_ftht_content *content); int ft_inter_htkey_cmp(const void *ref_key, const void *content); diff --git a/include/libft_lst.h b/include/libft_lst.h index 5669979..04b1dbf 100644 --- a/include/libft_lst.h +++ b/include/libft_lst.h @@ -13,29 +13,40 @@ #ifndef LIBFT_LST_H # define LIBFT_LST_H +/** +** \file libft_lst.h +** \brief Linked list Manipulation +*/ + # include # include "libft_types.h" # include "libft_algo.h" +/** +** \brief List struct +** \param data Pointer to node data +** \param next Pointer to next node or NULL if last node +*/ + typedef struct s_ftlst { - void *content; + void *data; struct s_ftlst *next; } t_ftlst; -typedef void (*t_ftdel_func)(void *); +typedef void (*t_ftdel_func)(void *); -t_ftlst *ft_lstnew(void const *content); -void ft_lstadd_front(t_ftlst **alst, t_ftlst *new); +t_ftlst *ft_lstnew(void const *data); int ft_lstsize(t_ftlst *lst); +void ft_lstpush_front(t_ftlst **alst, t_ftlst *new); +void ft_lstpush_back(t_ftlst **alst, t_ftlst *new); +void ft_lstpop_front(t_ftlst **lst, void (*del)(void *)); t_ftlst *ft_lstlast(t_ftlst *lst); -void ft_lstadd_back(t_ftlst **alst, t_ftlst *new); void ft_lstdelone(t_ftlst *lst, void (*del)(void *)); -void ft_lstclear(t_ftlst **lst, void (*del)(void *)); +void ft_lstdestroy(t_ftlst **lst, void (*del)(void *)); void ft_lstiter(t_ftlst *lst, void (*f)(void *)); t_ftlst *ft_lstmap(t_ftlst *lst, void *(*f)(void *), t_ftdel_func del); -void ft_lstpop_front(t_ftlst **lst, void (*del)(void *)); t_ftlst *ft_lstreverse_ret(t_ftlst *lst); void ft_lstreverse(t_ftlst **lst); void ft_lstremove_if(t_ftlst **lst, -- cgit From 9316f2063255bd4a0abd5c38d4c065969a8980bb Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 1 Apr 2020 18:10:36 +0200 Subject: Norm compliant comment format, dirty script for doxygen comments --- include/libft_ht.h | 10 +++++----- include/libft_lst.h | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/libft_ht.h b/include/libft_ht.h index 24abf95..10c6fc7 100644 --- a/include/libft_ht.h +++ b/include/libft_ht.h @@ -6,14 +6,14 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:36:09 by cacharle #+# #+# */ -/* Updated: 2020/02/28 12:18:19 by cacharle ### ########.fr */ +/* Updated: 2020/04/01 17:59:35 by charles ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef LIBFT_HT_H # define LIBFT_HT_H -/** +/* ** \file libft_ht.h ** \brief Hash table manipulation */ @@ -21,7 +21,7 @@ # include "libft.h" # include "libft_lst.h" -/** +/* ** \brief Hash table entry, key/value pair ** \param key String key ** \param value Pointer to data @@ -35,7 +35,7 @@ typedef struct s_ftht_entry typedef t_ftlst* t_ftht_bucket; -/** +/* ** \brief Hash table struct ** \param size Number of buckets ** \param buckets Bucket array @@ -59,7 +59,7 @@ t_ftht_entry *ft_htset(t_ftht *ht, char *key, void *value, void ft_htdelone(t_ftht *ht, char *key, void (*del)(t_ftht_entry*)); t_ftht_entry *ft_htentry_new(char *key, void *value); -void ft_htiter(t_ftht *ht, void (*f)(t_ftht_entry*)); +void ft_htiter(t_ftht *ht, void (*f)(t_ftht_entry*)); /* ** internals diff --git a/include/libft_lst.h b/include/libft_lst.h index 04b1dbf..d7157a9 100644 --- a/include/libft_lst.h +++ b/include/libft_lst.h @@ -6,14 +6,14 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:36:39 by cacharle #+# #+# */ -/* Updated: 2020/02/28 12:23:31 by cacharle ### ########.fr */ +/* Updated: 2020/04/01 17:59:50 by charles ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef LIBFT_LST_H # define LIBFT_LST_H -/** +/* ** \file libft_lst.h ** \brief Linked list Manipulation */ @@ -22,7 +22,7 @@ # include "libft_types.h" # include "libft_algo.h" -/** +/* ** \brief List struct ** \param data Pointer to node data ** \param next Pointer to next node or NULL if last node -- cgit From a1675f56b35f5521a91851bae8ca650706374ae6 Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 1 Apr 2020 21:21:10 +0200 Subject: Added vector --- include/libft_vec.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 include/libft_vec.h (limited to 'include') diff --git a/include/libft_vec.h b/include/libft_vec.h new file mode 100644 index 0000000..62ec257 --- /dev/null +++ b/include/libft_vec.h @@ -0,0 +1,46 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft_vec.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/01 18:57:16 by charles #+# #+# */ +/* Updated: 2020/04/01 19:40:53 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_VEC_H +# define LIBFT_VEC_H + +/* +** \file libft_vec.h +** \brief Vector manipulation +*/ + +# include +# include +# include "libft_mem.h" + +/* +** \brief Vector struct +** \param data Underlying array +** \param capacity Size of the underlying array +** \param size Number of element in the vector +*/ + +typedef struct s_ftvec +{ + void **data; + size_t capacity; + size_t size; +} t_ftvec; + +t_ftvec *ft_vecnew(size_t capacity); +void ft_vecdestroy(t_ftvec *vec, void (*del)(void *elem)); +t_ftvec *ft_vecgrow(t_ftvec *vec); +t_ftvec *ft_vecpush(t_ftvec *vec, void *pushed); +void ft_vecpop(t_ftvec *vec, void (*del)(void *elem)); +void ft_veciter(t_ftvec *vec, void (*f)(void *elem)); + +#endif -- cgit From 1925805cc760061d5742f9d215998561fcd45211 Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 1 Apr 2020 23:02:59 +0200 Subject: Added ft_vecremove, Updated README.md --- include/libft_vec.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/libft_vec.h b/include/libft_vec.h index 62ec257..f9199ba 100644 --- a/include/libft_vec.h +++ b/include/libft_vec.h @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 18:57:16 by charles #+# #+# */ -/* Updated: 2020/04/01 19:40:53 by charles ### ########.fr */ +/* Updated: 2020/04/01 22:53:33 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -42,5 +42,6 @@ t_ftvec *ft_vecgrow(t_ftvec *vec); t_ftvec *ft_vecpush(t_ftvec *vec, void *pushed); void ft_vecpop(t_ftvec *vec, void (*del)(void *elem)); void ft_veciter(t_ftvec *vec, void (*f)(void *elem)); +void ft_vecremove(t_ftvec *vec, size_t i, void (*del)(void *elem)); #endif -- cgit From a2452f88fffffe4e2a278578de5ac961858a5b72 Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 2 Apr 2020 11:20:44 +0200 Subject: Fixed ft_vecgrow, Added ft_vecinsert --- include/libft_vec.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/libft_vec.h b/include/libft_vec.h index f9199ba..c4e3e22 100644 --- a/include/libft_vec.h +++ b/include/libft_vec.h @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 18:57:16 by charles #+# #+# */ -/* Updated: 2020/04/01 22:53:33 by charles ### ########.fr */ +/* Updated: 2020/04/02 11:00:57 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -43,5 +43,6 @@ t_ftvec *ft_vecpush(t_ftvec *vec, void *pushed); void ft_vecpop(t_ftvec *vec, void (*del)(void *elem)); void ft_veciter(t_ftvec *vec, void (*f)(void *elem)); void ft_vecremove(t_ftvec *vec, size_t i, void (*del)(void *elem)); +t_ftvec *ft_vecinsert(t_ftvec *vec, size_t i, void *elem); #endif -- cgit From 948c0953527fe3bef28904b38a16a9e4342e7e98 Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 3 Apr 2020 00:29:26 +0200 Subject: Added ft_fnmatch function --- include/libft_str.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/libft_str.h b/include/libft_str.h index ea6115d..1b0703f 100644 --- a/include/libft_str.h +++ b/include/libft_str.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:39:22 by cacharle #+# #+# */ -/* Updated: 2020/02/28 12:09:56 by cacharle ### ########.fr */ +/* Updated: 2020/04/02 23:45:42 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,6 +14,7 @@ # define LIBFT_STR_H # include +# include # include "libft_ctype.h" typedef enum @@ -74,6 +75,12 @@ int ft_strnequ(char const *s1, char const *s2, size_t n); char *ft_strtolower(char *s); char *ft_strtoupper(char *s); +/* +** glob +*/ + +bool ft_fnmatch(const char *pattern, const char *string); + /* ** bloat ? */ -- cgit From d2feec1f97e9f8f201e56ad33662bb663c328a0a Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 3 Apr 2020 07:19:25 +0200 Subject: Changing hash table del function to regular one with a first order internal function, removing a few typedef to instead use standard types --- include/libft.h | 14 +++++++------- include/libft_algo.h | 11 ++++------- include/libft_def.h | 36 ++++++++++++++++++++++++++++++++++++ include/libft_ht.h | 50 ++++++++++++++++++++++++-------------------------- include/libft_lst.h | 2 +- include/libft_mem.h | 2 +- include/libft_types.h | 30 ------------------------------ 7 files changed, 73 insertions(+), 72 deletions(-) create mode 100644 include/libft_def.h delete mode 100644 include/libft_types.h (limited to 'include') diff --git a/include/libft.h b/include/libft.h index 74f074b..e982608 100644 --- a/include/libft.h +++ b/include/libft.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/10/07 09:45:02 by cacharle #+# #+# */ -/* Updated: 2020/02/10 02:19:47 by cacharle ### ########.fr */ +/* Updated: 2020/04/03 06:32:37 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,18 +17,18 @@ # include # include # include +# include # include # include -# include "libft_types.h" -# include "libft_ctype.h" -# include "libft_io.h" -# include "libft_mem.h" -# include "libft_str.h" - # ifdef __linux__ # include # define OPEN_MAX FOPEN_MAX # endif +# include "libft_io.h" +# include "libft_mem.h" +# include "libft_str.h" +# include "libft_ctype.h" + #endif diff --git a/include/libft_algo.h b/include/libft_algo.h index 7223e7b..04191e6 100644 --- a/include/libft_algo.h +++ b/include/libft_algo.h @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* ft_algo.h :+: :+: :+: */ +/* libft_algo.h :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/19 07:22:57 by cacharle #+# #+# */ -/* Updated: 2020/02/10 05:58:26 by cacharle ### ########.fr */ +/* Updated: 2020/04/03 07:05:04 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,11 +14,8 @@ # define LIBFT_ALGO_H # include -# include # include "libft_mem.h" -# include "libft_types.h" - -typedef int (*t_ftcompar_func)(const void*, const void*); +# include "libft_def.h" typedef struct { @@ -39,7 +36,7 @@ typedef struct s_ft_search_const t_ftcompar_func compar; } t_ftsearch_const; -t_ftbool ft_is_set(void *base, size_t nel, size_t width, +bool ft_is_set(void *base, size_t nel, size_t width, t_ftcompar_func compar); int ft_compar_int(const void *a, const void *b); void ft_qsort(void *base, size_t nel, size_t width, diff --git a/include/libft_def.h b/include/libft_def.h new file mode 100644 index 0000000..69a7655 --- /dev/null +++ b/include/libft_def.h @@ -0,0 +1,36 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft_def.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/01/31 10:36:56 by cacharle #+# #+# */ +/* Updated: 2020/04/03 07:04:57 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_DEF_H +# define LIBFT_DEF_H + +# include +# include + +# define TRUE 1 +# define FALSE 0 + +typedef unsigned char t_ftbyte; +typedef int t_ftbool; +typedef unsigned int t_ftsize; + +typedef char t_ftchar; +typedef unsigned char t_ftuchar; +typedef int t_ftint; +typedef unsigned int t_ftuint; +typedef long int t_ftlong; +typedef unsigned long int t_ftulong; + +typedef void (*t_ftdel_func)(void*); +typedef int (*t_ftcompar_func)(const void*, const void*); + +#endif diff --git a/include/libft_ht.h b/include/libft_ht.h index 10c6fc7..b3c1d2d 100644 --- a/include/libft_ht.h +++ b/include/libft_ht.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:36:09 by cacharle #+# #+# */ -/* Updated: 2020/04/01 17:59:35 by charles ### ########.fr */ +/* Updated: 2020/04/03 07:12:12 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,6 +19,7 @@ */ # include "libft.h" +# include "libft_def.h" # include "libft_lst.h" /* @@ -27,45 +28,42 @@ ** \param value Pointer to data */ -typedef struct s_ftht_entry +typedef struct s_ftht_entry { - char *key; - void *value; -} t_ftht_entry; - -typedef t_ftlst* t_ftht_bucket; + char *key; + void *value; +} t_ftht_entry; /* ** \brief Hash table struct ** \param size Number of buckets -** \param buckets Bucket array +** \param buckets Bucket array, each bucket is a linked list */ -typedef struct s_ftht +typedef struct s_ftht { - t_ftsize size; - t_ftht_bucket *buckets; -} t_ftht; - -typedef t_ftuint t_ftht_digest; + size_t size; + t_ftlst **buckets; +} t_ftht; -t_ftht_digest ft_hthash(t_ftht *ht, char *key); +size_t ft_hthash(t_ftht *ht, char *key); -t_ftht *ft_htnew(t_ftsize size); -void ft_htdestroy(t_ftht *ht, void (*del)(t_ftht_entry*)); -void *ft_htget(t_ftht *ht, char *key); -t_ftht_entry *ft_htset(t_ftht *ht, char *key, void *value, - void (*del)(t_ftht_entry*)); -void ft_htdelone(t_ftht *ht, char *key, - void (*del)(t_ftht_entry*)); -t_ftht_entry *ft_htentry_new(char *key, void *value); -void ft_htiter(t_ftht *ht, void (*f)(t_ftht_entry*)); +t_ftht *ft_htnew(size_t size); +void ft_htdestroy(t_ftht *ht, t_ftdel_func del); +void *ft_htget(t_ftht *ht, char *key); +t_ftht_entry *ft_htset(t_ftht *ht, char *key, void *value, + t_ftdel_func del); +void ft_htdelone(t_ftht *ht, char *key, t_ftdel_func del); +t_ftht_entry *ft_htentry_new(char *key, void *value); +void ft_htiter(t_ftht *ht, void (*f)(t_ftht_entry*)); /* ** internals */ -int ft_inter_htkey_cmp(const void *ref_key, - const void *content); +int ft_inter_htkey_cmp(const void *ref_key, const void *content); +void ft_inter_htdel_first_order(t_ftht_entry *entry); +void ft_inter_htdel_first_order_setup(t_ftdel_func del); +void ft_inter_htdel_first_order_teardown(void); #endif diff --git a/include/libft_lst.h b/include/libft_lst.h index d7157a9..2938bd2 100644 --- a/include/libft_lst.h +++ b/include/libft_lst.h @@ -19,7 +19,7 @@ */ # include -# include "libft_types.h" +# include "libft_def.h" # include "libft_algo.h" /* diff --git a/include/libft_mem.h b/include/libft_mem.h index 37c072e..26b4ccd 100644 --- a/include/libft_mem.h +++ b/include/libft_mem.h @@ -14,7 +14,7 @@ # define LIBFT_MEM_H # include -# include "libft_types.h" +# include "libft_def.h" void ft_bzero(void *s, size_t n); void *ft_memset(void *s, int c, size_t n); diff --git a/include/libft_types.h b/include/libft_types.h deleted file mode 100644 index 3987a80..0000000 --- a/include/libft_types.h +++ /dev/null @@ -1,30 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* libft_types.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/01/31 10:36:56 by cacharle #+# #+# */ -/* Updated: 2020/02/28 12:10:02 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef LIBFT_TYPES_H -# define LIBFT_TYPES_H - -# define TRUE 1 -# define FALSE 0 - -typedef unsigned char t_ftbyte; -typedef int t_ftbool; -typedef unsigned int t_ftsize; - -typedef char t_ftchar; -typedef unsigned char t_ftuchar; -typedef int t_ftint; -typedef unsigned int t_ftuint; -typedef long int t_ftlong; -typedef unsigned long int t_ftulong; - -#endif -- cgit From bf263810b0a47a68fae0681e6e6d2229a488c069 Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 3 Apr 2020 15:11:33 +0200 Subject: Added Dynamic string struct (no test, no doc) --- include/libft_dstr.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 include/libft_dstr.h (limited to 'include') diff --git a/include/libft_dstr.h b/include/libft_dstr.h new file mode 100644 index 0000000..13cb4e3 --- /dev/null +++ b/include/libft_dstr.h @@ -0,0 +1,35 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft_dstr.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/03 10:39:51 by charles #+# #+# */ +/* Updated: 2020/04/03 15:10:54 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_DSTR_H +# define LIBFT_DSTR_H + +# include +# include "libft_def.h" +# include "libft_str.h" +# include "libft_mem.h" + +typedef struct s_ftdstr +{ + char *str; + size_t length; + size_t capacity; +} t_ftdstr; + +t_ftdstr *ft_dstrnew(char *from); +void ft_dstrdestroy(t_ftdstr *dstr); +t_ftdstr *ft_dstrgrow(t_ftdstr *dstr, size_t at_least); +char *ft_dstrunwrap(t_ftdstr *dstr); +t_ftdstr *ft_dstrinsert(t_ftdstr *dstr, char *inserted, size_t i); +// t_ftdstr *ft_dstrreplace(t_ftdstr *dstr, char *from, char *to); + +#endif -- cgit From 636c3ff6b600c291a40877ac52d8b0a1a58b9b79 Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 3 Apr 2020 17:06:38 +0200 Subject: Added doubly linked list struct and basic functions on it --- include/libft_dlst.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 include/libft_dlst.h (limited to 'include') diff --git a/include/libft_dlst.h b/include/libft_dlst.h new file mode 100644 index 0000000..9870ea7 --- /dev/null +++ b/include/libft_dlst.h @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft_dlst.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/03 15:15:04 by charles #+# #+# */ +/* Updated: 2020/04/03 15:44:32 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_DLST_H +# define LIBFT_DLST_H + +# include +# include "libft_def.h" + +typedef struct s_ftdlst +{ + struct s_ftdlst *prev; + struct s_ftdlst *next; + void *data; +} t_ftdlst; + +t_ftdlst *ft_dlstnew(void *data); +void ft_dlstdestroy(t_ftdlst *dlst, t_ftdel_func del); +void ft_dlstdelone(t_ftdlst *dlst, t_ftdel_func del); + +#endif -- cgit From 51b845a6a202b50966f50e166cfb11bcbdccbe33 Mon Sep 17 00:00:00 2001 From: Charles Date: Sat, 4 Apr 2020 15:58:24 +0200 Subject: Added ft_strsjoin, ft_strsjoinf, ft_compar_str, ft_vecsort, ft_vecpush_safe --- include/libft_algo.h | 4 +++- include/libft_str.h | 10 +++++++++- include/libft_vec.h | 7 +++++-- 3 files changed, 17 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/libft_algo.h b/include/libft_algo.h index 04191e6..e726d1f 100644 --- a/include/libft_algo.h +++ b/include/libft_algo.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/19 07:22:57 by cacharle #+# #+# */ -/* Updated: 2020/04/03 07:05:04 by charles ### ########.fr */ +/* Updated: 2020/04/04 15:46:10 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,6 +16,7 @@ # include # include "libft_mem.h" # include "libft_def.h" +# include "libft_str.h" typedef struct { @@ -39,6 +40,7 @@ typedef struct s_ft_search_const bool ft_is_set(void *base, size_t nel, size_t width, t_ftcompar_func compar); int ft_compar_int(const void *a, const void *b); +int ft_compar_str(const void *s1_p, const void *s2_p); void ft_qsort(void *base, size_t nel, size_t width, t_ftcompar_func compar); int ft_mergesort(void *base, size_t nel, size_t width, diff --git a/include/libft_str.h b/include/libft_str.h index 1b0703f..2b105bf 100644 --- a/include/libft_str.h +++ b/include/libft_str.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:39:22 by cacharle #+# #+# */ -/* Updated: 2020/04/02 23:45:42 by charles ### ########.fr */ +/* Updated: 2020/04/04 14:41:46 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,6 +16,7 @@ # include # include # include "libft_ctype.h" +# include "libft_util.h" typedef enum { @@ -81,6 +82,13 @@ char *ft_strtoupper(char *s); bool ft_fnmatch(const char *pattern, const char *string); +/* +** NULL terminated string array +*/ + +char *ft_strsjoin(char **strs, char *delim); +char *ft_strsjoinf(char **strs, char *delim); + /* ** bloat ? */ diff --git a/include/libft_vec.h b/include/libft_vec.h index c4e3e22..8424bd5 100644 --- a/include/libft_vec.h +++ b/include/libft_vec.h @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 18:57:16 by charles #+# #+# */ -/* Updated: 2020/04/02 11:00:57 by charles ### ########.fr */ +/* Updated: 2020/04/04 15:55:29 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,8 +19,9 @@ */ # include -# include +# include "libft_def.h" # include "libft_mem.h" +# include "libft_algo.h" /* ** \brief Vector struct @@ -40,9 +41,11 @@ t_ftvec *ft_vecnew(size_t capacity); void ft_vecdestroy(t_ftvec *vec, void (*del)(void *elem)); t_ftvec *ft_vecgrow(t_ftvec *vec); t_ftvec *ft_vecpush(t_ftvec *vec, void *pushed); +t_ftvec *ft_vecpush_safe(t_ftvec *vec, void *pushed); void ft_vecpop(t_ftvec *vec, void (*del)(void *elem)); void ft_veciter(t_ftvec *vec, void (*f)(void *elem)); void ft_vecremove(t_ftvec *vec, size_t i, void (*del)(void *elem)); t_ftvec *ft_vecinsert(t_ftvec *vec, size_t i, void *elem); +void ft_vecsort(t_ftvec *vec, t_ftcompar_func cmp); #endif -- cgit From 42316d8393d32bd88fb8e0cba6825185f78dacd0 Mon Sep 17 00:00:00 2001 From: Charles Date: Sat, 4 Apr 2020 21:28:21 +0200 Subject: Added test and doc for dynamic string --- include/libft_dstr.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/libft_dstr.h b/include/libft_dstr.h index 13cb4e3..11bf2f4 100644 --- a/include/libft_dstr.h +++ b/include/libft_dstr.h @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/03 10:39:51 by charles #+# #+# */ -/* Updated: 2020/04/03 15:10:54 by charles ### ########.fr */ +/* Updated: 2020/04/04 21:18:48 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,6 +18,13 @@ # include "libft_str.h" # include "libft_mem.h" +/* +** \brief Dynamic string struct +** \param str Underlying null-terminated character array +** \param length Number of character (not including the '\0') +** \param capacity Maximum length - 1 of the current string +*/ + typedef struct s_ftdstr { char *str; @@ -30,6 +37,6 @@ void ft_dstrdestroy(t_ftdstr *dstr); t_ftdstr *ft_dstrgrow(t_ftdstr *dstr, size_t at_least); char *ft_dstrunwrap(t_ftdstr *dstr); t_ftdstr *ft_dstrinsert(t_ftdstr *dstr, char *inserted, size_t i); -// t_ftdstr *ft_dstrreplace(t_ftdstr *dstr, char *from, char *to); +// t_ftdstr *ft_dstrsubstitute(t_ftdstr *dstr, char *sub, size_t start, size_t end); #endif -- cgit From 65cf641e9533b190db870d0cc46f2f852239ebf6 Mon Sep 17 00:00:00 2001 From: Charles Date: Sat, 4 Apr 2020 23:36:19 +0200 Subject: Added test for ft_strsjoin, ft_strsjoinf, ft_vecpush_safe, Added doc for algo functions, tested functions --- include/libft_algo.h | 25 ++++++++++++++++++++++++- include/libft_def.h | 26 +++++++++++++++++++++++--- include/libft_dstr.h | 5 +++-- include/libft_ht.h | 3 ++- 4 files changed, 52 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/libft_algo.h b/include/libft_algo.h index e726d1f..e859de5 100644 --- a/include/libft_algo.h +++ b/include/libft_algo.h @@ -6,10 +6,15 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/19 07:22:57 by cacharle #+# #+# */ -/* Updated: 2020/04/04 15:46:10 by charles ### ########.fr */ +/* Updated: 2020/04/04 23:33:51 by charles ### ########.fr */ /* */ /* ************************************************************************** */ +/* +** \file libft_algo.h +** \brief Algorithms +*/ + #ifndef LIBFT_ALGO_H # define LIBFT_ALGO_H @@ -18,12 +23,26 @@ # include "libft_def.h" # include "libft_str.h" +/* +** \brief Range struct +** \param lo Lower bound +** \param hi Upper bound +*/ + typedef struct { int lo; int hi; } t_ftrange; +/* +** \brief Merge sort consts struct +** \param base Array to sort +** \param left Left subarray +** \param right Right subarray +** \note Only used internaly by ft_mergesort +*/ + struct s_merge_sorted_arrays { void *base; @@ -31,6 +50,10 @@ struct s_merge_sorted_arrays void *right; }; +/* +** remove this horror +*/ + typedef struct s_ft_search_const { const void *key; diff --git a/include/libft_def.h b/include/libft_def.h index 69a7655..7406959 100644 --- a/include/libft_def.h +++ b/include/libft_def.h @@ -6,10 +6,15 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:36:56 by cacharle #+# #+# */ -/* Updated: 2020/04/03 07:04:57 by charles ### ########.fr */ +/* Updated: 2020/04/04 21:40:37 by charles ### ########.fr */ /* */ /* ************************************************************************** */ +/* +** \file libft_def.h +** \brief Type and constant definition +*/ + #ifndef LIBFT_DEF_H # define LIBFT_DEF_H @@ -30,7 +35,22 @@ typedef unsigned int t_ftuint; typedef long int t_ftlong; typedef unsigned long int t_ftulong; -typedef void (*t_ftdel_func)(void*); -typedef int (*t_ftcompar_func)(const void*, const void*); +/* +** \brief Standard delete function +** \param x Resource to delete +*/ + +typedef void (*t_ftdel_func)(void *x); + +/* +** \brief Standard comparison function +** \param x1 Resource 1 +** \param x2 Resource 2 +** \return negative number if x1 < x2, +** 0 if x1 == x2, +** positive number if x1 > x2 +*/ + +typedef int (*t_ftcompar_func)(const void *x1, const void *x2); #endif diff --git a/include/libft_dstr.h b/include/libft_dstr.h index 11bf2f4..fbe69db 100644 --- a/include/libft_dstr.h +++ b/include/libft_dstr.h @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/03 10:39:51 by charles #+# #+# */ -/* Updated: 2020/04/04 21:18:48 by charles ### ########.fr */ +/* Updated: 2020/04/04 23:33:27 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -37,6 +37,7 @@ void ft_dstrdestroy(t_ftdstr *dstr); t_ftdstr *ft_dstrgrow(t_ftdstr *dstr, size_t at_least); char *ft_dstrunwrap(t_ftdstr *dstr); t_ftdstr *ft_dstrinsert(t_ftdstr *dstr, char *inserted, size_t i); -// t_ftdstr *ft_dstrsubstitute(t_ftdstr *dstr, char *sub, size_t start, size_t end); +t_ftdstr *ft_dstrsubstitute(t_ftdstr *dstr, char *sub, + size_t start, size_t end); #endif diff --git a/include/libft_ht.h b/include/libft_ht.h index b3c1d2d..c53ee4d 100644 --- a/include/libft_ht.h +++ b/include/libft_ht.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:36:09 by cacharle #+# #+# */ -/* Updated: 2020/04/03 07:12:12 by charles ### ########.fr */ +/* Updated: 2020/04/04 22:34:53 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,6 +21,7 @@ # include "libft.h" # include "libft_def.h" # include "libft_lst.h" +# include "libft_mem.h" /* ** \brief Hash table entry, key/value pair -- cgit From 944a236443bacf531085b346d06907b24e3739b1 Mon Sep 17 00:00:00 2001 From: Charles Date: Sun, 5 Apr 2020 01:11:50 +0200 Subject: Added ft_dstrerase, ft_dstrsubstitute --- include/libft_dstr.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/libft_dstr.h b/include/libft_dstr.h index fbe69db..732e475 100644 --- a/include/libft_dstr.h +++ b/include/libft_dstr.h @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/03 10:39:51 by charles #+# #+# */ -/* Updated: 2020/04/04 23:33:27 by charles ### ########.fr */ +/* Updated: 2020/04/05 00:37:05 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -37,7 +37,8 @@ void ft_dstrdestroy(t_ftdstr *dstr); t_ftdstr *ft_dstrgrow(t_ftdstr *dstr, size_t at_least); char *ft_dstrunwrap(t_ftdstr *dstr); t_ftdstr *ft_dstrinsert(t_ftdstr *dstr, char *inserted, size_t i); -t_ftdstr *ft_dstrsubstitute(t_ftdstr *dstr, char *sub, +void ft_dstrerase(t_ftdstr *dstr, size_t start, size_t len); +t_ftdstr *ft_dstrsubstitute(t_ftdstr *dstr, char *replacement, size_t start, size_t end); #endif -- cgit From 3a2d19df9e509d0b015c786eb02f8315ff0ad91c Mon Sep 17 00:00:00 2001 From: Charles Date: Sun, 5 Apr 2020 14:05:43 +0200 Subject: Renamed ft_substr to ft_strsub, Added ft_strsubf, ft_strcat3 --- include/libft_str.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/libft_str.h b/include/libft_str.h index 2b105bf..195e750 100644 --- a/include/libft_str.h +++ b/include/libft_str.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:39:22 by cacharle #+# #+# */ -/* Updated: 2020/04/04 14:41:46 by charles ### ########.fr */ +/* Updated: 2020/04/05 13:52:10 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -52,7 +52,8 @@ int ft_atoi(const char *nptr); void ft_striter(char *s, void (*f)(char *)); void ft_striteri(char *s, void (*f)(unsigned int, char *)); -char *ft_substr(char const *s, unsigned int start, size_t len); +char *ft_strsub(char const *s, size_t start, size_t len); +char *ft_strsubf(char const *s, size_t start, size_t len); char *ft_strjoin(char const *s1, char const *s2); char *ft_strjoin3(char const *s1, char const *s2, char const *s3); char *ft_strjoinf(char const *s1, char const *s2, t_ftstrjoinf_tag tag); @@ -75,6 +76,7 @@ int ft_strequ(char const *s1, char const *s2); int ft_strnequ(char const *s1, char const *s2, size_t n); char *ft_strtolower(char *s); char *ft_strtoupper(char *s); +char *ft_strcat3(char *dest, const char *src1, const char *src2); /* ** glob -- cgit From a3c962abbcdae671b886c4c76ddb9bb8ac27c958 Mon Sep 17 00:00:00 2001 From: Charles Date: Sun, 26 Apr 2020 21:04:43 +0200 Subject: Added ft_btsorted_insert, ft_btsorted_search, Red-black tree struct (not tested) --- include/libft_bt.h | 37 ++++++++++++++++----- include/libft_rbt.h | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+), 8 deletions(-) create mode 100644 include/libft_rbt.h (limited to 'include') diff --git a/include/libft_bt.h b/include/libft_bt.h index 6e2cc91..7bd7eb4 100644 --- a/include/libft_bt.h +++ b/include/libft_bt.h @@ -6,23 +6,44 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/07 21:26:34 by cacharle #+# #+# */ -/* Updated: 2020/02/07 21:34:52 by cacharle ### ########.fr */ +/* Updated: 2020/04/26 19:45:56 by charles ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef LIBFT_BT_H # define LIBFT_BT_H +/* +** \file libft_bt.h +** \brief Binary tree +*/ + # include -typedef struct s_ftbtree +/* +** \brief Binary tree struct +** \param left Left node +** \param right Right node +** \param data Node data +*/ + +typedef struct s_ftbt { - void *data; - struct s_ftbtree *left; - struct s_ftbtree *right; -} t_ftbtree; + struct s_ftbt *left; + struct s_ftbt *right; + void *data; +} t_ftbt; + +t_ftbt *ft_btnew(void *data); +void ft_btdestroy(t_ftbt *tree, void (*del)(void *data)); -t_ftbtree *ft_btnew(void *data); -void ft_btdestroy(t_ftbtree *tree, void (*del)(void *data)); +t_ftbt *ft_btsorted_insert( + t_ftbt *tree, + void *data, + int (*cmp)(void*, void*)); +void *ft_btsorted_search( + t_ftbt *tree, + void *ref, + int (*cmp)(void*, void*)); #endif diff --git a/include/libft_rbt.h b/include/libft_rbt.h new file mode 100644 index 0000000..57653cc --- /dev/null +++ b/include/libft_rbt.h @@ -0,0 +1,96 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft_rbt.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/26 16:09:51 by charles #+# #+# */ +/* Updated: 2020/04/26 20:25:36 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_RBT_H +# define LIBFT_RBT_H + +/* +** \file libft_rbt.h +** \brief Red-black tree +** +** Rules: (from wikipedia) +** 1. Each node is either red or black. +** 2. The root is black. This rule is sometimes omitted. Since the root can +** always be changed from red to black, but not necessarily vice versa, +** this rule has little effect on analysis. +** 3. All leaves (NULL) are black. +** 4. If a node is red, then both its children are black. +** 5. Every path from a given node to any of its descendant NULL nodes goes +** through the same number of black nodes. +** +** +** Unbalance case: +** +** 1. Node and parent are both red +** +** B1 +** \ left rot color swap +** > R2 --> R2 --> B2 +** \ / \ / \ +** > R3 B1 R3 R1 R3 +** +** 2. Node and parent are both red and uncle node is red +** +** B2 R2 +** / \ color swap / \ +** uncle> R1 R3 --> B1 B3 +** \ \ +** R4 R4 +*/ + +# include + +/* +** \brief Red-black tree color enum +** \param FTRBT_COLOR_RED color red +** \param FTRBT_COLOR_BLACK color black +*/ + +enum e_ftrbt_color +{ + FTRBT_COLOR_RED = 0, + FTRBT_COLOR_BLACK, +}; + +/* +** \brief Red-black tree struct +** \param left Left node +** \param right Right node +** \param data Pointer to data +** \param parent Parent node +** \param color Color of the node +** \note The first 3 attricutes are the same +** as t_ftbt (binary tree) struct +** which means that we can use all functions +** of binary tree on red-black tree. +*/ + +typedef struct s_ftrbt +{ + struct s_ftrbt *left; + struct s_ftrbt *right; + void *data; + struct s_ftrbt *parent; + enum e_ftrbt_color color; +} t_ftrbt; + +t_ftrbt *ft_rbtnew(void *data, enum e_ftrbt_color color); +void ft_rbtrotate_right(t_ftrbt **tree); +void ft_rbtrotate_left(t_ftrbt **tree); + +t_ftrbt *ft_rbtinsert( + t_ftrbt *tree, + void *data, + int (*cmp)(void*, void*)); + + +#endif -- cgit From b5124347359833fcde33452978c62133879c6c9e Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 8 May 2020 13:40:45 +0200 Subject: Fixed bug in ft_split --- include/libft_str.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/libft_str.h b/include/libft_str.h index d65c90f..a373e86 100644 --- a/include/libft_str.h +++ b/include/libft_str.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:39:22 by cacharle #+# #+# */ -/* Updated: 2020/02/28 12:09:56 by cacharle ### ########.fr */ +/* Updated: 2020/05/08 13:39:12 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,6 +16,7 @@ # include # include "libft_ctype.h" # include "libft_mem.h" +# include "libft_util.h" typedef enum { -- cgit From d3fb362c2e0b83cc9754a05ae5bc4a68a5f9269d Mon Sep 17 00:00:00 2001 From: Charles Date: Sun, 10 May 2020 22:01:15 +0200 Subject: Added ft_strtof, ft_atof, ft_vectobuf32, ft_split_len (not tested) --- include/libft_io.h | 16 ++++++++-------- include/libft_str.h | 4 +++- include/libft_util.h | 4 +++- include/libft_vec.h | 3 ++- 4 files changed, 16 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/libft_io.h b/include/libft_io.h index 418b230..e59d70c 100644 --- a/include/libft_io.h +++ b/include/libft_io.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:35:43 by cacharle #+# #+# */ -/* Updated: 2020/02/28 12:09:11 by cacharle ### ########.fr */ +/* Updated: 2020/05/09 11:16:36 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -29,18 +29,18 @@ void ft_putnbr_fd(int n, int fd); char ft_getchar(void); -# ifndef FTNL_BUFFER_SIZE -# define FTNL_BUFFER_SIZE 32 +# ifndef FT_GETLINE_BUFFER_SIZE +# define FT_GETLINE_BUFFER_SIZE 32 # endif -# define FTNL_STATUS_LINE 1 -# define FTNL_STATUS_EOF 0 -# define FTNL_STATUS_ERROR -1 +# define FT_LINE 1 +# define FT_EOF 0 +# define FT_ERROR -1 /* -** get_next_line.c +** getline.c */ -int ft_next_line(int fd, char **line); +int ft_getline(int fd, char **line); #endif diff --git a/include/libft_str.h b/include/libft_str.h index 07a5fe0..83c4428 100644 --- a/include/libft_str.h +++ b/include/libft_str.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:39:22 by cacharle #+# #+# */ -/* Updated: 2020/05/09 12:29:21 by charles ### ########.fr */ +/* Updated: 2020/05/10 21:05:21 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -64,6 +64,8 @@ int ft_strcount(char *str, char c); char *ft_itoa(int n); int ft_atoi_strict(const char *s); long ft_strtol(const char *s, char **endptr, int base); +float ft_strtof(const char *nptr, char **endptr); +float ft_atof(const char *nptr); int ft_strcasecmp(const char *s1, const char *s2); int ft_strncasecmp(const char *s1, const char *s2, size_t n); size_t ft_strspn(const char *s, const char *charset); diff --git a/include/libft_util.h b/include/libft_util.h index 7a9e056..99e7a00 100644 --- a/include/libft_util.h +++ b/include/libft_util.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/27 17:51:36 by cacharle #+# #+# */ -/* Updated: 2020/02/27 17:52:16 by cacharle ### ########.fr */ +/* Updated: 2020/05/10 21:02:02 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,7 +14,9 @@ # define LIBFT_UTIL_H # include +# include void *ft_split_destroy(char **strs); +size_t ft_split_len(char **split); #endif diff --git a/include/libft_vec.h b/include/libft_vec.h index 8424bd5..a5f22dd 100644 --- a/include/libft_vec.h +++ b/include/libft_vec.h @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 18:57:16 by charles #+# #+# */ -/* Updated: 2020/04/04 15:55:29 by charles ### ########.fr */ +/* Updated: 2020/05/10 21:09:25 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -47,5 +47,6 @@ void ft_veciter(t_ftvec *vec, void (*f)(void *elem)); void ft_vecremove(t_ftvec *vec, size_t i, void (*del)(void *elem)); t_ftvec *ft_vecinsert(t_ftvec *vec, size_t i, void *elem); void ft_vecsort(t_ftvec *vec, t_ftcompar_func cmp); +void *ft_vectobuf32(t_ftvec *vec); #endif -- cgit From a4b9cda7d6733f2b077f8586e3b3e69351e7dfba Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 11 May 2020 10:54:58 +0200 Subject: Added ft_getfile --- include/libft_io.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/libft_io.h b/include/libft_io.h index e59d70c..ce3c632 100644 --- a/include/libft_io.h +++ b/include/libft_io.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:35:43 by cacharle #+# #+# */ -/* Updated: 2020/05/09 11:16:36 by charles ### ########.fr */ +/* Updated: 2020/05/11 09:57:42 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -29,8 +29,14 @@ void ft_putnbr_fd(int n, int fd); char ft_getchar(void); +# ifndef FT_GETFILE_BUFFER_SIZE +# define FT_GETFILE_BUFFER_SIZE 64 +# endif + +char *ft_getfile(int fd); + # ifndef FT_GETLINE_BUFFER_SIZE -# define FT_GETLINE_BUFFER_SIZE 32 +# define FT_GETLINE_BUFFER_SIZE 64 # endif # define FT_LINE 1 -- cgit From b9f000a80cbba38b8f21c9737a42f07573ec7b91 Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 11 May 2020 16:14:38 +0200 Subject: Moved util/ft_split* in str, Added ft_memjoin and ft_memjoinf1, Modified ft_getfile so that it can read non-ascii file --- include/libft_io.h | 31 +++++++++++++++++++------------ include/libft_mem.h | 34 ++++++++++++++++++---------------- include/libft_rbt.h | 3 +-- include/libft_str.h | 5 +++-- include/libft_util.h | 22 ---------------------- 5 files changed, 41 insertions(+), 54 deletions(-) delete mode 100644 include/libft_util.h (limited to 'include') diff --git a/include/libft_io.h b/include/libft_io.h index ce3c632..b64603b 100644 --- a/include/libft_io.h +++ b/include/libft_io.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:35:43 by cacharle #+# #+# */ -/* Updated: 2020/05/11 09:57:42 by charles ### ########.fr */ +/* Updated: 2020/05/11 16:12:41 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,23 +17,30 @@ # include # include # include "libft.h" +# include "libft_def.h" -void ft_putendl(char *s); -void ft_putchar(char c); -void ft_putstr(char const *s); -void ft_putnbr(int n); -void ft_putchar_fd(char c, int fd); -void ft_putstr_fd(char *s, int fd); -void ft_putendl_fd(char *s, int fd); -void ft_putnbr_fd(int n, int fd); +void ft_putendl(char *s); +void ft_putchar(char c); +void ft_putstr(char const *s); +void ft_putnbr(int n); +void ft_putchar_fd(char c, int fd); +void ft_putstr_fd(char *s, int fd); +void ft_putendl_fd(char *s, int fd); +void ft_putnbr_fd(int n, int fd); -char ft_getchar(void); +char ft_getchar(void); # ifndef FT_GETFILE_BUFFER_SIZE # define FT_GETFILE_BUFFER_SIZE 64 # endif -char *ft_getfile(int fd); +typedef struct s_ftmem +{ + void *data; + size_t size; +} t_ftmem; + +int ft_getfile(int fd, t_ftmem *mem); # ifndef FT_GETLINE_BUFFER_SIZE # define FT_GETLINE_BUFFER_SIZE 64 @@ -47,6 +54,6 @@ char *ft_getfile(int fd); ** getline.c */ -int ft_getline(int fd, char **line); +int ft_getline(int fd, char **line); #endif diff --git a/include/libft_mem.h b/include/libft_mem.h index f26180d..8f7b276 100644 --- a/include/libft_mem.h +++ b/include/libft_mem.h @@ -6,34 +6,36 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:35:57 by cacharle #+# #+# */ -/* Updated: 2020/05/09 12:28:55 by charles ### ########.fr */ +/* Updated: 2020/05/11 15:22:04 by charles ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef LIBFT_MEM_H # define LIBFT_MEM_H -# include +# include # include "libft_def.h" -void ft_bzero(void *s, size_t n); -void *ft_memset(void *s, int c, size_t n); -void *ft_memcpy(void *dest, const void *src, size_t n); -void *ft_memccpy(void *dest, const void *src, int c, size_t n); -void *ft_memmove(void *dst, const void *src, size_t len); -void *ft_memchr(const void *s, int c, size_t n); -int ft_memcmp(const void *s1, const void *s2, size_t n); -void *ft_calloc(size_t count, size_t size); -void ft_memswap(void *a, void *b, size_t size); -void *ft_memmem(const void *big, size_t big_len, - const void *little, size_t little_len); -void ft_memset_pattern4(void *b, const void *pattern4, - size_t len); +void ft_bzero(void *s, size_t n); +void *ft_memset(void *s, int c, size_t n); +void *ft_memcpy(void *dest, const void *src, size_t n); +void *ft_memccpy(void *dest, const void *src, int c, size_t n); +void *ft_memmove(void *dst, const void *src, size_t len); +void *ft_memchr(const void *s, int c, size_t n); +int ft_memcmp(const void *s1, const void *s2, size_t n); +void *ft_calloc(size_t count, size_t size); +void ft_memswap(void *a, void *b, size_t size); +void ft_memset_pattern4(void *b, const void *pattern4, size_t len); +void *ft_memjoin(void *m1, size_t m1_size, void *m2, size_t m2_size); +void *ft_memjoinf1(void *m1, size_t m1_size, void *m2, size_t m2_size); +void *ft_memmem( + const void *big, size_t big_len, + const void *little, size_t little_len); /* ** bloat ? */ -void ft_memdel(void **ap); +void ft_memdel(void **ap); #endif diff --git a/include/libft_rbt.h b/include/libft_rbt.h index 57653cc..6865cdf 100644 --- a/include/libft_rbt.h +++ b/include/libft_rbt.h @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/26 16:09:51 by charles #+# #+# */ -/* Updated: 2020/04/26 20:25:36 by charles ### ########.fr */ +/* Updated: 2020/05/11 16:11:16 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -92,5 +92,4 @@ t_ftrbt *ft_rbtinsert( void *data, int (*cmp)(void*, void*)); - #endif diff --git a/include/libft_str.h b/include/libft_str.h index 83c4428..383c393 100644 --- a/include/libft_str.h +++ b/include/libft_str.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:39:22 by cacharle #+# #+# */ -/* Updated: 2020/05/10 21:05:21 by charles ### ########.fr */ +/* Updated: 2020/05/11 15:52:40 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,7 +17,6 @@ # include # include "libft_ctype.h" # include "libft_mem.h" -# include "libft_util.h" typedef enum { @@ -93,6 +92,8 @@ bool ft_fnmatch(const char *pattern, const char *string); char *ft_strsjoin(char **strs, char *delim); char *ft_strsjoinf(char **strs, char *delim); +void *ft_strsdestroy(char **strs); +size_t ft_strslen(char **strs); /* ** bloat ? diff --git a/include/libft_util.h b/include/libft_util.h deleted file mode 100644 index 99e7a00..0000000 --- a/include/libft_util.h +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* libft_util.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/02/27 17:51:36 by cacharle #+# #+# */ -/* Updated: 2020/05/10 21:02:02 by charles ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef LIBFT_UTIL_H -# define LIBFT_UTIL_H - -# include -# include - -void *ft_split_destroy(char **strs); -size_t ft_split_len(char **split); - -#endif -- cgit From 966eb29634a84496e0851ef2b5a7d64f413d33ed Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 12 May 2020 19:10:14 +0200 Subject: Added ft_veciter_ret --- include/libft_io.h | 4 ++-- include/libft_vec.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/libft_io.h b/include/libft_io.h index b64603b..faeade4 100644 --- a/include/libft_io.h +++ b/include/libft_io.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:35:43 by cacharle #+# #+# */ -/* Updated: 2020/05/11 16:12:41 by charles ### ########.fr */ +/* Updated: 2020/05/12 18:00:55 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -43,7 +43,7 @@ typedef struct s_ftmem int ft_getfile(int fd, t_ftmem *mem); # ifndef FT_GETLINE_BUFFER_SIZE -# define FT_GETLINE_BUFFER_SIZE 64 +# define FT_GETLINE_BUFFER_SIZE 1 # endif # define FT_LINE 1 diff --git a/include/libft_vec.h b/include/libft_vec.h index a5f22dd..c31b36e 100644 --- a/include/libft_vec.h +++ b/include/libft_vec.h @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 18:57:16 by charles #+# #+# */ -/* Updated: 2020/05/10 21:09:25 by charles ### ########.fr */ +/* Updated: 2020/05/12 18:36:00 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -44,6 +44,7 @@ t_ftvec *ft_vecpush(t_ftvec *vec, void *pushed); t_ftvec *ft_vecpush_safe(t_ftvec *vec, void *pushed); void ft_vecpop(t_ftvec *vec, void (*del)(void *elem)); void ft_veciter(t_ftvec *vec, void (*f)(void *elem)); +void ft_veciter_ret(t_ftvec *vec, void *(*f)(void *elem)); void ft_vecremove(t_ftvec *vec, size_t i, void (*del)(void *elem)); t_ftvec *ft_vecinsert(t_ftvec *vec, size_t i, void *elem); void ft_vecsort(t_ftvec *vec, t_ftcompar_func cmp); -- cgit From d4aeabeac0a8bd1665b14aacf487df17198c1ab9 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 12 May 2020 21:40:41 +0200 Subject: Fixing/refactoring ft_getline, fixed/normed ft_memchr, added ft_strmove --- include/libft_io.h | 10 ++++++++-- include/libft_str.h | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/libft_io.h b/include/libft_io.h index faeade4..ab40875 100644 --- a/include/libft_io.h +++ b/include/libft_io.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:35:43 by cacharle #+# #+# */ -/* Updated: 2020/05/12 18:00:55 by charles ### ########.fr */ +/* Updated: 2020/05/12 20:36:36 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -33,6 +33,9 @@ char ft_getchar(void); # ifndef FT_GETFILE_BUFFER_SIZE # define FT_GETFILE_BUFFER_SIZE 64 # endif +# if FT_GETFILE_BUFFER_SIZE <= 0 +# error "FT_GETFILE_BUFFER_SIZE must be > 0" +# endif typedef struct s_ftmem { @@ -43,7 +46,10 @@ typedef struct s_ftmem int ft_getfile(int fd, t_ftmem *mem); # ifndef FT_GETLINE_BUFFER_SIZE -# define FT_GETLINE_BUFFER_SIZE 1 +# define FT_GETLINE_BUFFER_SIZE 64 +# endif +# if FT_GETLINE_BUFFER_SIZE <= 0 +# error "FT_GETLINE_BUFFER_SIZE must be > 0" # endif # define FT_LINE 1 diff --git a/include/libft_str.h b/include/libft_str.h index 383c393..41e81ac 100644 --- a/include/libft_str.h +++ b/include/libft_str.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:39:22 by cacharle #+# #+# */ -/* Updated: 2020/05/11 15:52:40 by charles ### ########.fr */ +/* Updated: 2020/05/12 20:47:36 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -79,6 +79,7 @@ int ft_strnequ(char const *s1, char const *s2, size_t n); char *ft_strtolower(char *s); char *ft_strtoupper(char *s); char *ft_strcat3(char *dest, const char *src1, const char *src2); +char *ft_strmove(char *dest, const char *src); /* ** glob -- cgit