lem_in/srcs/lst_ind.c
Tanguy MAZE 15669b7402 not quite there yet but nearly ^^
WIP for the algorithm not to pass on previously used node
2019-04-01 19:06:19 +02:00

40 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* lst_ind.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/27 14:56:55 by tmaze #+# #+# */
/* Updated: 2019/04/01 17:37:51 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
#include "lem_in.h"
t_ind *lst_indadd(t_ind **lst, int ind)
{
t_ind *new;
if ((new = (t_ind*)ft_memalloc(sizeof(t_ind))) != NULL)
{
new->index = ind;
new->weight = 1;
new->next = *lst;
*lst = new;
}
return (new);
}
void lst_inddel(t_ind **lst)
{
t_ind *tmp;
while (lst && *lst != NULL)
{
tmp = *lst;
*lst = (*lst)->next;
ft_memdel((void**)&tmp);
}
}