aboutsummaryrefslogtreecommitdiff
path: root/list.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2019-10-29 01:57:41 +0100
committerCharles <sircharlesaze@gmail.com>2019-10-29 02:02:09 +0100
commit87bce91050b56915dcf5964f6f66d5f47299e7f3 (patch)
tree8c8fef15ffb962cfa860181ffad3fdd52c71b4f0 /list.c
parentf6ee1462e26d723cf5d53157eadaff2804d18c3a (diff)
downloadft_printf-87bce91050b56915dcf5964f6f66d5f47299e7f3.tar.gz
ft_printf-87bce91050b56915dcf5964f6f66d5f47299e7f3.tar.bz2
ft_printf-87bce91050b56915dcf5964f6f66d5f47299e7f3.zip
Reworking, binary flags, extract advance
- Binary flags attribute instead of multiple bool - Extract doesnst strdup fmt each time, just advance the current pointer - In parsing push front then reverse - Moved some functions to libf
Diffstat (limited to 'list.c')
-rw-r--r--list.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/list.c b/list.c
index e6a9460..b87c69a 100644
--- a/list.c
+++ b/list.c
@@ -1,3 +1,15 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* list.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2019/10/29 00:14:50 by cacharle #+# #+# */
+/* Updated: 2019/10/29 00:14:51 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
#include <stdlib.h>
#include "header.h"
@@ -6,7 +18,7 @@ t_flist *list_new(t_pformat *content)
t_flist *lst;
if ((lst = (t_flist*)malloc(sizeof(t_flist))) == NULL)
- return NULL;
+ return (NULL);
lst->content = content;
lst->next = NULL;
return (lst);
@@ -21,7 +33,6 @@ void *list_destroy(t_flist **lst)
return (NULL);
}
-
void list_push_front(t_flist **lst, t_flist *new)
{
if (lst == NULL || new == NULL)
@@ -42,20 +53,16 @@ void list_pop_front(t_flist **lst)
*lst = tmp;
}
-void list_reverse(t_flist **lst)
+t_flist *list_reverse(t_flist *lst)
{
- t_flist *cursor;
- t_flist *prev;
t_flist *tmp;
- prev = NULL;
- cursor = *lst;
- while (cursor != NULL)
- {
- tmp = cursor;
- cursor->next = prev;
- prev = cursor;
- cursor = tmp->next;
- }
- *lst = prev;
+ if (lst == NULL)
+ return (NULL);
+ if (lst->next == NULL)
+ return (lst);
+ tmp = list_reverse(lst->next);
+ lst->next->next = lst;
+ lst->next = NULL;
+ return (tmp);
}