aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-08-20 23:21:43 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-08-20 23:21:43 +0200
commitd3cf16e078e92ab85e5ad2f30f2c07ce382fd98e (patch)
tree371f93b833356e665d29cc6ca52f58e6162c14c5 /src
parentffaebd5ffe714799254d6c520c4ad19a0157e672 (diff)
downloadlibft-d3cf16e078e92ab85e5ad2f30f2c07ce382fd98e.tar.gz
libft-d3cf16e078e92ab85e5ad2f30f2c07ce382fd98e.tar.bz2
libft-d3cf16e078e92ab85e5ad2f30f2c07ce382fd98e.zip
Added ft_lstpush_front_node, ft_lstdestroy returns NULL
Diffstat (limited to 'src')
-rw-r--r--src/lst/ft_lstdestroy.c10
-rw-r--r--src/lst/ft_lstpush_front_node.c23
-rw-r--r--src/vec/ft_vecreserve.c4
3 files changed, 31 insertions, 6 deletions
diff --git a/src/lst/ft_lstdestroy.c b/src/lst/ft_lstdestroy.c
index 35da2a5..2af6fb7 100644
--- a/src/lst/ft_lstdestroy.c
+++ b/src/lst/ft_lstdestroy.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/09 09:02:39 by cacharle #+# #+# */
-/* Updated: 2019/11/20 04:02:37 by cacharle ### ########.fr */
+/* Updated: 2020/08/20 14:36:17 by charles ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,15 +15,17 @@
/*
** \brief Destroy a list and set his pointer to NULL
** \param del Delete Function for data of each node
+** \return returns NULL
*/
-void ft_lstdestroy(t_ftlst **lst, void (*del)(void *))
+void *ft_lstdestroy(t_ftlst **lst, void (*del)(void *))
{
if (lst == NULL)
- return ;
+ return (NULL);
if (*lst == NULL)
- return ;
+ return (NULL);
ft_lstdestroy(&((*lst)->next), del);
ft_lstdelone(*lst, del);
*lst = NULL;
+ return (NULL);
}
diff --git a/src/lst/ft_lstpush_front_node.c b/src/lst/ft_lstpush_front_node.c
new file mode 100644
index 0000000..f6ff694
--- /dev/null
+++ b/src/lst/ft_lstpush_front_node.c
@@ -0,0 +1,23 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_lstpush_front_node.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <me@cacharle.xyz> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/08/20 14:38:18 by charles #+# #+# */
+/* Updated: 2020/08/20 14:41:14 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft_lst.h"
+
+t_ftlst *ft_lstpush_front_node(t_ftlst **lst, void *data)
+{
+ t_ftlst *pushed;
+
+ if (data == NULL || (pushed = ft_lstnew(data)) == NULL)
+ return (NULL);
+ ft_lstpush_front(lst, pushed);
+ return (*lst);
+}
diff --git a/src/vec/ft_vecreserve.c b/src/vec/ft_vecreserve.c
index c2e7bcc..105eb16 100644
--- a/src/vec/ft_vecreserve.c
+++ b/src/vec/ft_vecreserve.c
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/07/15 17:22:08 by charles #+# #+# */
-/* Updated: 2020/07/15 18:30:58 by charles ### ########.fr */
+/* Updated: 2020/08/20 23:21:19 by charles ### ########.fr */
/* */
/* ************************************************************************** */
@@ -19,7 +19,7 @@
** \return The Vector or NULL on error
*/
-t_ftvec *ft_vecreserve(t_ftvec *vec, size_t capacity)
+t_ftvec *ft_vecreserve(t_ftvec *vec, size_t capacity)
{
while (vec->capacity < capacity)
{