-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfill_list.c
71 lines (64 loc) · 1.85 KB
/
fill_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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fill_list.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jraymond <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/12/04 16:08:09 by jraymond #+# #+# */
/* Updated: 2017/12/08 17:11:40 by jauplat ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
t_list_minos *ft_lst_creat_elem(int letter)
{
t_list_minos *new;
if (!(new = (t_list_minos*)malloc(sizeof(t_list_minos))))
ft_error(1);
new->letter = 'A' + letter;
if (!(new->coord = (int*)malloc(sizeof(int) * 9)))
ft_error(1);
new->next = NULL;
return (new);
}
static void ft_lst_add_elem_back(t_list_minos *begin_list, int letter)
{
while (begin_list->next)
begin_list = begin_list->next;
begin_list->next = ft_lst_creat_elem(letter);
}
static void ft_memmove_tab(int *dest, int *src)
{
int x;
x = 0;
while (*src != 42)
{
dest++;
src++;
x++;
}
while (x != 0)
{
*dest = *src;
dest--;
src--;
x--;
}
}
void ft_fill_lst_coord(t_list_minos *begin_list, int letter, \
int *coord_minos)
{
if (letter == 0)
{
ft_memmove_tab(begin_list->coord, coord_minos);
}
else
{
ft_lst_add_elem_back(begin_list, letter);
while (begin_list->next)
{
begin_list = begin_list->next;
}
ft_memmove_tab(begin_list->coord, coord_minos);
}
}