-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoint_utils.c
More file actions
48 lines (43 loc) · 1.53 KB
/
point_utils.c
File metadata and controls
48 lines (43 loc) · 1.53 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* point_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mvalient <mvalient@student.42urduliz.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/10 19:22:34 by mvalient #+# #+# */
/* Updated: 2022/12/21 12:52:37 by mvalient ### ########.fr */
/* */
/* ************************************************************************** */
#include "fdf.h"
void ft_add_point(t_point **list, int x, int y, int z)
{
t_point *new_point;
t_point *node;
if (DEBUG)
ft_printf("Point to be stored: %d,%d,%d\n", x, y, z);
new_point = malloc(sizeof(t_point));
new_point->x = x;
new_point->y = y;
new_point->z = z;
new_point->next = NULL;
if (!(*list))
{
*list = new_point;
return ;
}
node = *list;
while (node->next)
node = node->next;
node->next = new_point;
}
void ft_clear_point_list(t_point **point_list_head, void (*del)(void *))
{
t_point *about_to_del;
while (*point_list_head)
{
about_to_del = *point_list_head;
*point_list_head = (*point_list_head)->next;
del(about_to_del);
}
}