aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ht/ft_htdelone.c12
-rw-r--r--src/ht/ft_htdestroy.c13
-rw-r--r--src/ht/ft_htentry_new.c (renamed from src/ht/ft_htcontent_new.c)16
-rw-r--r--src/ht/ft_htget.c12
-rw-r--r--src/ht/ft_hthash.c7
-rw-r--r--src/ht/ft_htiter.c10
-rw-r--r--src/ht/ft_htnew.c12
-rw-r--r--src/ht/ft_htset.c36
-rw-r--r--src/ht/ft_inter_htkey_cmp.c2
-rw-r--r--src/io/ft_printf/internals/list.c4
-rw-r--r--src/io/ft_printf/internals/parse.c2
-rw-r--r--src/lst/ft_lstbsearch.c4
-rw-r--r--src/lst/ft_lstdelone.c10
-rw-r--r--src/lst/ft_lstdestroy.c (renamed from src/lst/ft_lstclear.c)12
-rw-r--r--src/lst/ft_lstiter.c10
-rw-r--r--src/lst/ft_lstlast.c8
-rw-r--r--src/lst/ft_lstlfind.c2
-rw-r--r--src/lst/ft_lstlsearch.c2
-rw-r--r--src/lst/ft_lstmap.c21
-rw-r--r--src/lst/ft_lstnew.c12
-rw-r--r--src/lst/ft_lstpop_front.c6
-rw-r--r--src/lst/ft_lstpush_back.c (renamed from src/lst/ft_lstadd_back.c)10
-rw-r--r--src/lst/ft_lstpush_front.c (renamed from src/lst/ft_lstadd_front.c)10
-rw-r--r--src/lst/ft_lstremove_if.c10
-rw-r--r--src/lst/ft_lstreverse.c5
-rw-r--r--src/lst/ft_lstreverse_ret.c6
-rw-r--r--src/lst/ft_lstsize.c8
-rw-r--r--src/lst/ft_lstsort.c6
-rw-r--r--src/lst/ft_lstsorted_merge.c10
29 files changed, 182 insertions, 96 deletions
diff --git a/src/ht/ft_htdelone.c b/src/ht/ft_htdelone.c
index e3bb355..3672b23 100644
--- a/src/ht/ft_htdelone.c
+++ b/src/ht/ft_htdelone.c
@@ -13,13 +13,17 @@
#include "libft.h"
#include "libft_ht.h"
-/*
-** Delete one hash table entry at `key`.
+/**
+** \brief Delete one hash table entry
+** \param key Key of entry to delete
+** \param del Function to destroy the entry
+** \warning The del function HAS to free the key
+** \note Do nothing if their is to entry which correspond to key
*/
-void ft_htdelone(t_ftht *ht, char *key, void (*del)(t_ftht_content*))
+void ft_htdelone(t_ftht *ht, char *key, void (*del)(t_ftht_entry*))
{
- ft_lstremove_if(ht->entries + ft_hthash(ht, key),
+ ft_lstremove_if(ht->buckets + ft_hthash(ht, key),
ft_inter_htkey_cmp, key,
(void (*)(void*))del);
}
diff --git a/src/ht/ft_htdestroy.c b/src/ht/ft_htdestroy.c
index a788a78..ef4b257 100644
--- a/src/ht/ft_htdestroy.c
+++ b/src/ht/ft_htdestroy.c
@@ -13,17 +13,18 @@
#include "libft.h"
#include "libft_ht.h"
-/*
-** Destroy an hash table.
-** The `del` function is used to destroy each key/value pair
+/**
+** \brief Destroy an hash table.
+** \param del Function to delete each entry
+** \warning The del function HAS to free the key
*/
-void ft_htdestroy(t_ftht *ht, void (*del)(t_ftht_content*))
+void ft_htdestroy(t_ftht *ht, void (*del)(t_ftht_entry*))
{
if (ht == NULL)
return ;
while (ht->size-- > 0)
- ft_lstclear(ht->entries + ht->size, (void (*)(void*))del);
- free(ht->entries);
+ ft_lstdestroy(ht->buckets + ht->size, (void (*)(void*))del);
+ free(ht->buckets);
free(ht);
}
diff --git a/src/ht/ft_htcontent_new.c b/src/ht/ft_htentry_new.c
index 7dd4f20..03c0980 100644
--- a/src/ht/ft_htcontent_new.c
+++ b/src/ht/ft_htentry_new.c
@@ -1,7 +1,7 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
-/* ft_htcontent_new.c :+: :+: :+: */
+/* ft_htentry_new.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
@@ -13,19 +13,19 @@
#include "libft.h"
#include "libft_ht.h"
-/*
-** Create a new hash table key/value pair.
-** `key` is always duplicated.
-** Return a pointer to the created content or NULL is an allocation failed.
+/**
+** \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_content *ft_htcontent_new(char *key, void *value)
+t_ftht_entry *ft_htentry_new(char *key, void *value)
{
- t_ftht_content *content;
+ t_ftht_entry *content;
if (key == NULL)
return (NULL);
- if ((content = (t_ftht_content*)malloc(sizeof(t_ftht_content))) == NULL)
+ if ((content = (t_ftht_entry*)malloc(sizeof(t_ftht_entry))) == NULL)
return (NULL);
if ((content->key = ft_strdup(key)) == NULL)
{
diff --git a/src/ht/ft_htget.c b/src/ht/ft_htget.c
index 94a4164..6b5df48 100644
--- a/src/ht/ft_htget.c
+++ b/src/ht/ft_htget.c
@@ -13,9 +13,11 @@
#include "libft.h"
#include "libft_ht.h"
-/*
-** Retrieve a value with associated key.
-** Returns NULL if there is no value at `key`.
+/**
+** \brief Retrieve a value with a key
+** \param ht Hash table where key is searched
+** \param key Searched key
+** \return Value void pointer at key or NULL if not found
*/
void *ft_htget(t_ftht *ht, char *key)
@@ -27,8 +29,8 @@ void *ft_htget(t_ftht *ht, char *key)
if (ht == NULL || key == NULL)
return (NULL);
digest = ft_hthash(ht, key);
- found = ft_lstlfind(ht->entries[digest], ft_inter_htkey_cmp, key);
+ found = ft_lstlfind(ht->buckets[digest], ft_inter_htkey_cmp, key);
if (found == NULL)
return (NULL);
- return (((t_ftht_content*)found->content)->value);
+ return (((t_ftht_entry*)found->data)->value);
}
diff --git a/src/ht/ft_hthash.c b/src/ht/ft_hthash.c
index ba922e7..2670e31 100644
--- a/src/ht/ft_hthash.c
+++ b/src/ht/ft_hthash.c
@@ -12,8 +12,11 @@
#include "libft_ht.h"
-/*
-** Hash a string according to the size of the hash table.
+/**
+** \brief Hash a string
+** \param ht So that the index is in the hash table bound
+** \param key String to hash
+** \return Hash
*/
// maybe use a less efficient but understandable function
diff --git a/src/ht/ft_htiter.c b/src/ht/ft_htiter.c
index 5473412..e5ab2eb 100644
--- a/src/ht/ft_htiter.c
+++ b/src/ht/ft_htiter.c
@@ -1,17 +1,19 @@
#include "libft_ht.h"
-/*
-** Iterate function `f` over every pair in `ht`.
+/**
+** \brief Iterate over entry of hash table
+** \param ht Iterated hash table
+** \param f Function applied to each entry
*/
-void ft_htiter(t_ftht *ht, void (*f)(t_ftht_content*))
+void ft_htiter(t_ftht *ht, void (*f)(t_ftht_entry*))
{
size_t i;
i = 0;
while (i < ht->size)
{
- ft_lstiter(ht->entries[i], (void (*)(void*))f);
+ ft_lstiter(ht->buckets[i], (void (*)(void*))f);
i++;
}
}
diff --git a/src/ht/ft_htnew.c b/src/ht/ft_htnew.c
index 465eabf..e28b544 100644
--- a/src/ht/ft_htnew.c
+++ b/src/ht/ft_htnew.c
@@ -13,10 +13,10 @@
#include "libft.h"
#include "libft_ht.h"
-/*
-** Create a new hash table.
-** `size` is the size of the underlying array of linked list (buckets)
-** Return NULL is an allocation failed.
+/**
+** \brief Create a new hash table.
+** \param size Size of the underlying array of linked list (buckets)
+** \return Created hash table or NULL is an allocation failed
*/
t_ftht *ft_htnew(t_ftsize size)
@@ -27,8 +27,8 @@ t_ftht *ft_htnew(t_ftsize size)
return (NULL);
if ((ht = (t_ftht*)malloc(sizeof(t_ftht))) == NULL)
return (NULL);
- ht->entries = (t_ftht_entry*)ft_calloc(size, sizeof(t_ftht_entry));
- if (ht->entries == NULL)
+ ht->buckets = (t_ftht_bucket*)ft_calloc(size, sizeof(t_ftht_entry));
+ if (ht->buckets == NULL)
{
free(ht);
return (NULL);
diff --git a/src/ht/ft_htset.c b/src/ht/ft_htset.c
index 0755889..9738c14 100644
--- a/src/ht/ft_htset.c
+++ b/src/ht/ft_htset.c
@@ -13,39 +13,43 @@
#include "libft.h"
#include "libft_ht.h"
-/*
-** Create/Update a entry in an hash table.
-** If `key` already exist in `ht`, updates only the list element content.
-** else create a new list node in addition the list content.
-** Return a pointer to the created entry, NULL if an allocation failed.
+/**
+** \brief Create/Update a entry in hash table.
+** \note If `key` already exist in `ht`, only updates the list node content.
+** Else create a new list node in addition the list content.
+** \param ht Hash table where the entry is modified
+** \param key Key of the new entry
+** \param value Value of the new entry
+** \param del Destroy function in case the entry is modified.
+** \return Pointer to the created entry, NULL if an allocation failed.
*/
-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*))
{
t_ftht_digest digest;
- t_ftht_content *content;
- t_ftht_entry entry;
+ t_ftht_entry *content;
+ t_ftht_bucket bucket;
t_ftlst *tmp;
if (ht == NULL || key == NULL)
return (NULL);
- if ((content = ft_htcontent_new(key, value)) == NULL)
+ if ((content = ft_htentry_new(key, value)) == NULL)
return (NULL);
digest = ft_hthash(ht, key);
- tmp = ft_lstlfind(ht->entries[digest], ft_inter_htkey_cmp, key);
+ tmp = ft_lstlfind(ht->buckets[digest], ft_inter_htkey_cmp, key);
if (tmp != NULL)
{
if (del != NULL)
- del(tmp->content);
- tmp->content = content;
- return ((t_ftht_content*)tmp->content);
+ del(tmp->data);
+ tmp->data = content;
+ return ((t_ftht_entry*)tmp->data);
}
- if ((entry = ft_lstnew(content)) == NULL)
+ if ((bucket = ft_lstnew(content)) == NULL)
{
del(content);
return (NULL);
}
- ft_lstadd_front(ht->entries + digest, entry);
+ ft_lstpush_front(ht->buckets + digest, bucket);
return (content);
}
diff --git a/src/ht/ft_inter_htkey_cmp.c b/src/ht/ft_inter_htkey_cmp.c
index 397177e..e8a0375 100644
--- a/src/ht/ft_inter_htkey_cmp.c
+++ b/src/ht/ft_inter_htkey_cmp.c
@@ -21,5 +21,5 @@ 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));
+ return (ft_strcmp((char*)ref_key, ((t_ftht_entry*)content)->key));
}
diff --git a/src/io/ft_printf/internals/list.c b/src/io/ft_printf/internals/list.c
index 99491f4..37f8013 100644
--- a/src/io/ft_printf/internals/list.c
+++ b/src/io/ft_printf/internals/list.c
@@ -18,7 +18,7 @@ t_flist *list_new(t_pformat *content)
if ((lst = (t_flist*)malloc(sizeof(t_flist))) == NULL)
return (NULL);
- lst->content = content;
+ lst->data = content;
lst->next = NULL;
return (lst);
}
@@ -47,7 +47,7 @@ void list_pop_front(t_flist **lst)
if (lst == NULL || *lst == NULL)
return ;
tmp = (*lst)->next;
- free((*lst)->content);
+ free((*lst)->data);
free(*lst);
*lst = tmp;
}
diff --git a/src/io/ft_printf/internals/parse.c b/src/io/ft_printf/internals/parse.c
index 33928a0..4650481 100644
--- a/src/io/ft_printf/internals/parse.c
+++ b/src/io/ft_printf/internals/parse.c
@@ -28,7 +28,7 @@ int parse(const char *format, t_flist **flist)
if ((tmp = list_new(parsed)) == NULL)
return ((int)list_destroy(flist));
list_push_front(flist, tmp);
- format += (*flist)->content->fmt_len;
+ format += (*flist)->data->fmt_len;
}
*flist = list_reverse(*flist);
return (1);
diff --git a/src/lst/ft_lstbsearch.c b/src/lst/ft_lstbsearch.c
index d3dc7e4..0c48eb0 100644
--- a/src/lst/ft_lstbsearch.c
+++ b/src/lst/ft_lstbsearch.c
@@ -46,11 +46,11 @@ static t_ftlst *st_lstbsearch_rec(t_ftlst *lst, t_ftlst *last,
return (NULL);
if (mid->next == NULL)
{
- if (cmp(ref, mid->content) == 0)
+ if (cmp(ref, mid->data) == 0)
return (mid);
return (NULL);
}
- res = cmp(ref, mid->next->content);
+ res = cmp(ref, mid->next->data);
if (res < 0)
return (st_lstbsearch_rec(lst, mid, cmp, ref));
else if (res > 0)
diff --git a/src/lst/ft_lstdelone.c b/src/lst/ft_lstdelone.c
index 63dcc35..40e25cd 100644
--- a/src/lst/ft_lstdelone.c
+++ b/src/lst/ft_lstdelone.c
@@ -1,7 +1,7 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
-/* ft_lstdelone_bonus.c :+: :+: :+: */
+/* ft_lstdelone.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
@@ -10,14 +10,18 @@
/* */
/* ************************************************************************** */
-#include "libft.h"
#include "libft_lst.h"
+/**
+** \brief Delete list node
+** \param del Delete function for node's data
+*/
+
void ft_lstdelone(t_ftlst *lst, void (*del)(void *))
{
if (lst == NULL)
return ;
if (del != NULL)
- (*del)(lst->content);
+ (*del)(lst->data);
free(lst);
}
diff --git a/src/lst/ft_lstclear.c b/src/lst/ft_lstdestroy.c
index 0bacb4f..5e55f04 100644
--- a/src/lst/ft_lstclear.c
+++ b/src/lst/ft_lstdestroy.c
@@ -1,7 +1,7 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
-/* ft_lstclear_bonus.c :+: :+: :+: */
+/* ft_lstdestroy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
@@ -10,16 +10,20 @@
/* */
/* ************************************************************************** */
-#include "libft.h"
#include "libft_lst.h"
-void ft_lstclear(t_ftlst **lst, void (*del)(void *))
+/**
+** \brief Destroy a list and set his pointer to NULL
+** \param del Delete Function for data of each node
+*/
+
+void ft_lstdestroy(t_ftlst **lst, void (*del)(void *))
{
if (lst == NULL)
return ;
if (*lst == NULL)
return ;
- ft_lstclear(&((*lst)->next), del);
+ ft_lstdestroy(&((*lst)->next), del);
ft_lstdelone(*lst, del);
*lst = NULL;
}
diff --git a/src/lst/ft_lstiter.c b/src/lst/ft_lstiter.c
index 9b2895b..39d870b 100644
--- a/src/lst/ft_lstiter.c
+++ b/src/lst/ft_lstiter.c
@@ -1,7 +1,7 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
-/* ft_lstiter_bonus.c :+: :+: :+: */
+/* ft_lstiter.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
@@ -10,16 +10,20 @@
/* */
/* ************************************************************************** */
-#include "libft.h"
#include "libft_lst.h"
+/**
+** \brief Iterate of list
+** \param f Funtion applied to data of each node
+*/
+
void ft_lstiter(t_ftlst *lst, void (*f)(void *))
{
if (f == NULL)
return ;
while (lst != NULL)
{
- (*f)(lst->content);
+ (*f)(lst->data);
lst = lst->next;
}
}
diff --git a/src/lst/ft_lstlast.c b/src/lst/ft_lstlast.c
index 728cbf2..12fdeee 100644
--- a/src/lst/ft_lstlast.c
+++ b/src/lst/ft_lstlast.c
@@ -1,7 +1,7 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
-/* ft_lstlast_bonus.c :+: :+: :+: */
+/* ft_lstlast.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
@@ -10,9 +10,13 @@
/* */
/* ************************************************************************** */
-#include "libft.h"
#include "libft_lst.h"
+/**
+** \brief Last node
+** \return List's last node
+*/
+
t_ftlst *ft_lstlast(t_ftlst *lst)
{
if (lst == NULL)
diff --git a/src/lst/ft_lstlfind.c b/src/lst/ft_lstlfind.c
index c399b6e..fd7e688 100644
--- a/src/lst/ft_lstlfind.c
+++ b/src/lst/ft_lstlfind.c
@@ -16,7 +16,7 @@ t_ftlst *ft_lstlfind(t_ftlst *lst, t_ftcompar_func cmp, const void *ref)
{
if (lst == NULL)
return (NULL);
- if (cmp(ref, lst->content) == 0)
+ if (cmp(ref, lst->data) == 0)
return (lst);
return (ft_lstlfind(lst->next, cmp, ref));
}
diff --git a/src/lst/ft_lstlsearch.c b/src/lst/ft_lstlsearch.c
index f59b5de..11c528c 100644
--- a/src/lst/ft_lstlsearch.c
+++ b/src/lst/ft_lstlsearch.c
@@ -16,7 +16,7 @@ t_ftlst *ft_lstlsearch(t_ftlst *lst, t_ftcompar_func cmp, const void *ref)
{
if (lst == NULL)
return (ft_lstnew(ref));
- if (cmp(ref, lst->content) == 0)
+ if (cmp(ref, lst->data) == 0)
return (lst);
if (lst->next == NULL)
{
diff --git a/src/lst/ft_lstmap.c b/src/lst/ft_lstmap.c
index dda15de..bf96892 100644
--- a/src/lst/ft_lstmap.c
+++ b/src/lst/ft_lstmap.c
@@ -1,7 +1,7 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
-/* ft_lstmap_bonus.c :+: :+: :+: */
+/* ft_lstmap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
@@ -10,9 +10,16 @@
/* */
/* ************************************************************************** */
-#include "libft.h"
#include "libft_lst.h"
+/**
+** \brief Clone a list and map a function to each node data
+** \param lst Origin list
+** \param f Function applied to each node's data
+** \param del Delete function for cleanning up in case of failed allocation
+** \return Mapped clone list
+*/
+
t_ftlst *ft_lstmap(t_ftlst *lst, void *(*f)(void *), void (*del)(void *))
{
t_ftlst *mapped;
@@ -23,12 +30,12 @@ t_ftlst *ft_lstmap(t_ftlst *lst, void *(*f)(void *), void (*del)(void *))
mapped = NULL;
while (lst != NULL)
{
- if ((tmp = ft_lstnew((*f)(lst->content))) == NULL)
+ if ((tmp = ft_lstnew((*f)(lst->data))) == NULL)
{
- ft_lstclear(&mapped, del);
+ ft_lstdestroy(&mapped, del);
return (NULL);
}
- ft_lstadd_back(&mapped, tmp);
+ ft_lstpush_back(&mapped, tmp);
lst = lst->next;
}
return (mapped);
@@ -41,9 +48,9 @@ t_ftlst *ft_lstmap(t_ftlst *lst, void *(*f)(void *), void (*del)(void *))
**
** if (lst == NULL)
** return (NULL);
-** if ((tmp = ft_lstnew(lst->content)) == NULL)
+** if ((tmp = ft_lstnew(lst->data)) == NULL)
** return (NULL);
-** tmp->content = (*f)(tmp->content);
+** tmp->data = (*f)(tmp->data);
** tmp->next = ft_lstmap(lst->next, f);
** return (tmp);
*/
diff --git a/src/lst/ft_lstnew.c b/src/lst/ft_lstnew.c
index 11cf223..41c8153 100644
--- a/src/lst/ft_lstnew.c
+++ b/src/lst/ft_lstnew.c
@@ -1,7 +1,7 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
-/* ft_lstnew_bonus.c :+: :+: :+: */
+/* ft_lstnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
@@ -10,16 +10,20 @@
/* */
/* ************************************************************************** */
-#include "libft.h"
#include "libft_lst.h"
-t_ftlst *ft_lstnew(void const *content)
+/**
+** \brief Create a list node
+** \param data Pointer to data of node
+*/
+
+t_ftlst *ft_lstnew(void const *data)
{
t_ftlst *elem;
if ((elem = (t_ftlst*)malloc(sizeof(t_ftlst))) == NULL)
return (NULL);
- elem->content = (void*)content;
+ elem->data = (void*)data;
elem->next = NULL;
return (elem);
}
diff --git a/src/lst/ft_lstpop_front.c b/src/lst/ft_lstpop_front.c
index 5bf2c60..798bf83 100644
--- a/src/lst/ft_lstpop_front.c
+++ b/src/lst/ft_lstpop_front.c
@@ -10,9 +10,13 @@
/* */
/* ************************************************************************** */
-#include "libft.h"
#include "libft_lst.h"
+/**
+** \brief Delete head node and replace it with next node
+** \param del Delete function for node data
+*/
+
void ft_lstpop_front(t_ftlst **lst, void (*del)(void *))
{
t_ftlst *tmp;
diff --git a/src/lst/ft_lstadd_back.c b/src/lst/ft_lstpush_back.c
index 8f39a75..372c18c 100644
--- a/src/lst/ft_lstadd_back.c
+++ b/src/lst/ft_lstpush_back.c
@@ -1,7 +1,7 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
-/* ft_lstadd_back_bonus.c :+: :+: :+: */
+/* ft_lstpush_back.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
@@ -10,10 +10,14 @@
/* */
/* ************************************************************************** */
-#include "libft.h"
#include "libft_lst.h"
-void ft_lstadd_back(t_ftlst **alst, t_ftlst *new)
+/**
+** \brief Push new node to the list end
+** \param new Pushed node
+*/
+
+void ft_lstpush_back(t_ftlst **alst, t_ftlst *new)
{
if (alst == NULL)
return ;
diff --git a/src/lst/ft_lstadd_front.c b/src/lst/ft_lstpush_front.c
index bcd5ad9..c17a586 100644
--- a/src/lst/ft_lstadd_front.c
+++ b/src/lst/ft_lstpush_front.c
@@ -1,7 +1,7 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
-/* ft_lstadd_front_bonus.c :+: :+: :+: */
+/* ft_lstpush_front.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
@@ -10,10 +10,14 @@
/* */
/* ************************************************************************** */
-#include "libft.h"
#include "libft_lst.h"
-void ft_lstadd_front(t_ftlst **alst, t_ftlst *new)
+/**
+** \brief Push node to list front
+** \param new Pushed node
+*/
+
+void ft_lstpush_front(t_ftlst **alst, t_ftlst *new)
{
if (alst == NULL || new == NULL)
return ;
diff --git a/src/lst/ft_lstremove_if.c b/src/lst/ft_lstremove_if.c
index 03643fa..fdac710 100644
--- a/src/lst/ft_lstremove_if.c
+++ b/src/lst/ft_lstremove_if.c
@@ -10,9 +10,15 @@
/* */
/* ************************************************************************** */
-#include "libft.h"
#include "libft_lst.h"
+/**
+** \brief Remove node on some condition
+** \param cmp Comparison function, return 0 if equal
+** \param ref Reference data passed has the first arg of `cmp`
+** \param del Delete function to free removed node data
+*/
+
void ft_lstremove_if(t_ftlst **lst, t_ftcompar_func cmp,
const void *ref, t_ftdel_func del)
{
@@ -20,7 +26,7 @@ void ft_lstremove_if(t_ftlst **lst, t_ftcompar_func cmp,
if (lst == NULL || *lst == NULL)
return ;
- if (cmp(ref, (*lst)->content) == 0)
+ if (cmp(ref, (*lst)->data) == 0)
{
saved_next = (*lst)->next;
ft_lstdelone(*lst, del);
diff --git a/src/lst/ft_lstreverse.c b/src/lst/ft_lstreverse.c
index 61c9daf..fd5259b 100644
--- a/src/lst/ft_lstreverse.c
+++ b/src/lst/ft_lstreverse.c
@@ -10,9 +10,12 @@
/* */
/* ************************************************************************** */
-#include "libft.h"
#include "libft_lst.h"
+/**
+** \brief Reverse a list
+*/
+
void ft_lstreverse(t_ftlst **lst)
{
*lst = ft_lstreverse_ret(*lst);
diff --git a/src/lst/ft_lstreverse_ret.c b/src/lst/ft_lstreverse_ret.c
index c115ac5..259af9e 100644
--- a/src/lst/ft_lstreverse_ret.c
+++ b/src/lst/ft_lstreverse_ret.c
@@ -10,9 +10,13 @@
/* */
/* ************************************************************************** */
-#include "libft.h"
#include "libft_lst.h"
+/**
+** \brief Reverse list
+** \return Pointer to reversed list
+*/
+
t_ftlst *ft_lstreverse_ret(t_ftlst *lst)
{
t_ftlst *tmp;
diff --git a/src/lst/ft_lstsize.c b/src/lst/ft_lstsize.c
index 922b581..6a92b99 100644
--- a/src/lst/ft_lstsize.c
+++ b/src/lst/ft_lstsize.c
@@ -1,7 +1,7 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
-/* ft_lstsize_bonus.c :+: :+: :+: */
+/* ft_lstsize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
@@ -10,9 +10,13 @@
/* */
/* ************************************************************************** */
-#include "libft.h"
#include "libft_lst.h"
+/**
+** \brief List size
+** \return Number of node in list
+*/
+
int ft_lstsize(t_ftlst *lst)
{
int counter;
diff --git a/src/lst/ft_lstsort.c b/src/lst/ft_lstsort.c
index e1c9913..fbd046a 100644
--- a/