added protection on double pipes
This commit is contained in:
@@ -6,13 +6,29 @@
|
||||
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/03/29 07:17:06 by mndhlovu #+# #+# */
|
||||
/* Updated: 2019/04/09 18:18:59 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/04/11 20:34:58 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "lem_in.h"
|
||||
|
||||
int lm_adj_parser(t_lmdata *lmdata, t_holder *holder)
|
||||
static int is_link_in(t_lmdata *data, int src, int dest)
|
||||
{
|
||||
t_ind *it;
|
||||
if (src < data->nb_nodes)
|
||||
{
|
||||
it = data->adj[src];
|
||||
while (it)
|
||||
{
|
||||
if (it->index == dest)
|
||||
return (1);
|
||||
it = it->next;
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
int lm_adj_parser(t_lmdata *lmdata, t_holder *holder)
|
||||
{
|
||||
t_temp *data;
|
||||
|
||||
@@ -23,7 +39,8 @@ int lm_adj_parser(t_lmdata *lmdata, t_holder *holder)
|
||||
{
|
||||
while (data)
|
||||
{
|
||||
lst_indadd_link(lmdata, data->src_ind, data->dest_ind);
|
||||
if (!is_link_in(lmdata, data->src_ind, data->dest_ind))
|
||||
lst_indadd_link(lmdata, data->src_ind, data->dest_ind);
|
||||
data = data->next;
|
||||
}
|
||||
return (1);
|
||||
|
Reference in New Issue
Block a user