modify map printing system
added functions to create, print and clear map when it's valid
This commit is contained in:
61
srcs/print_map.c
Normal file
61
srcs/print_map.c
Normal file
@@ -0,0 +1,61 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* print_map.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/24 17:35:29 by tmaze #+# #+# */
|
||||
/* Updated: 2019/04/24 18:09:57 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "lem_in.h"
|
||||
|
||||
void del_map(t_lmdata *data)
|
||||
{
|
||||
t_rdata *tmp;
|
||||
|
||||
while (data->map)
|
||||
{
|
||||
ft_strdel(&(data->map->line));
|
||||
tmp = data->map;
|
||||
data->map = data->map->next;
|
||||
ft_memdel((void**)&tmp);
|
||||
}
|
||||
}
|
||||
|
||||
void print_map(t_lmdata *data)
|
||||
{
|
||||
t_rdata *it;
|
||||
|
||||
it = data->map;
|
||||
while (it)
|
||||
{
|
||||
ft_printf("%s\n", it->line);
|
||||
it = it->next;
|
||||
}
|
||||
del_map(&(data->map));
|
||||
}
|
||||
|
||||
int add_line_map(t_lmdata *data, char *line)
|
||||
{
|
||||
t_rdata *it;
|
||||
t_rdata *new;
|
||||
|
||||
if ((new = (t_rdata*)ft_memalloc(sizeof(t_rdata))) == NULL)
|
||||
return (1);
|
||||
new->line = line;
|
||||
new->next = NULL;
|
||||
if (data->map == NULL)
|
||||
data->map = new;
|
||||
else
|
||||
{
|
||||
it = data->map;
|
||||
while (it->next)
|
||||
it = it->next;
|
||||
it->next = new;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user