lem_in/srcs/lm_check_errors.c
Mthandazo Ndhlovu eb85b914a4 Leaks and error checking almost done
function to clean traces of holder is done.
Error checking before adjacency list creation is done also.
Now focusing on breaking the parser with
invalid maps. It should be ready in a day.
2019-04-11 12:52:14 +02:00

53 lines
1.7 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* lm_check_errors.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/02 08:39:09 by mndhlovu #+# #+# */
/* Updated: 2019/04/11 12:48:13 by mndhlovu ### ########.fr */
/* */
/* ************************************************************************** */
#include "lem_in.h"
int lm_check_room_before(char **tab, t_syntax *synt)
{
if (tab[0] != NULL && tab[1] != NULL && tab[2] != NULL)
{
if (!lm_validate_rooms(tab[0], tab[1], tab[2]))
{
synt->v_error = 1;
return (0);
}
}
return (1);
}
void lm_clear_unv(t_holder *holder)
{
t_temp *data;
t_temp *flush;
data = holder->data;
while (tmp)
{
flush = data;
data = data->next;
free(flush);
flush = NULL;
}
holder->data = NULL;
}
int lm_verify_cmd(t_syntax *synt, t_holder *holder, t_lmdata *data)
{
if (synt->s_cmd && synt->e_cmd && !synt->v_error
&& !synt->l_error && !synt->e_error && !synt->s_error
&& synt->nb_state && (holder->count > 0)
&& (data->nb_nodes > 0))
return (1);
return (0);
}