diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-10-12 10:43:01 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-10-12 11:48:54 +0200 |
| commit | 6ea4606cd3f74377691d200d69df8398f90cc2ff (patch) | |
| tree | f354459b9054f5bd23a7508c12ef1589af38e75a /list.c | |
| parent | bddc2d153a4c47257740a0bf0651513058a612d5 (diff) | |
| download | ft_printf-6ea4606cd3f74377691d200d69df8398f90cc2ff.tar.gz ft_printf-6ea4606cd3f74377691d200d69df8398f90cc2ff.tar.bz2 ft_printf-6ea4606cd3f74377691d200d69df8398f90cc2ff.zip | |
Basic conversion parsing
Using a list to store each format conversion informations.
Diffstat (limited to 'list.c')
| -rw-r--r-- | list.c | 54 |
1 files changed, 54 insertions, 0 deletions
@@ -0,0 +1,54 @@ +#include <stdlib.h> +#include "header.h" + +t_list *list_new(t_pformat *data) +{ + t_list *list; + + if ((list = (t_list*)malloc(sizeof(t_list))) == NULL) + return NULL; + list->data = data; + list->next = NULL; + return (list); +} + +t_list *list_destroy(t_list *list) +{ + while (list != NULL) + list_pop_front(&list); + return (NULL); +} + + +void list_push_front(t_list **list, t_list *new_front) +{ + new_front->next = *list; + *list = new_front; +} + +void list_push_back(t_list **list, t_list *new_back) +{ + t_list *cursor; + + if (*list == NULL) + { + *list = new_back; + return ; + } + cursor = *list; + while (cursor->next != NULL) + cursor = cursor->next; + cursor->next = new_back; +} + +void list_pop_front(t_list **list) +{ + t_list *tmp; + + if (*list == NULL) + return ; + tmp = (*list)->next; + free((*list)->data); + free(*list); + *list = tmp; +} |
