-
Notifications
You must be signed in to change notification settings - Fork 2
/
word_list.c
45 lines (39 loc) · 1.52 KB
/
word_list.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* word_list.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jkong <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/19 03:35:56 by jkong #+# #+# */
/* Updated: 2022/06/24 19:32:27 by jkong ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
#include "safe_mem.h"
#include "string_buffer.h"
#include "generic_list.h"
void append_word_list(t_list_word **list_ptr, char *str, t_word_flags flags)
{
t_list_word *elem;
elem = calloc_safe(1, sizeof(*elem));
elem->word.str = str;
elem->word.flags = flags;
list_append((void *)list_ptr, (void *)elem);
}
static int _clear_w_list(t_list_word *elem)
{
dispose_word(&elem->word);
free(elem);
return (0);
}
void delete_word_list(t_list_word *list)
{
list_walk((void *)list, _clear_w_list);
}
void singleton_word_list(t_list_word *ptr, t_word *word)
{
ptr->word.str = word->str;
ptr->word.flags = word->flags;
ptr->next = NULL;
}