clean up still in progress
eliminated most of the leaks of the parser norming still need to be done
This commit is contained in:
@@ -6,17 +6,12 @@
|
||||
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/03/25 06:31:37 by mndhlovu #+# #+# */
|
||||
/* Updated: 2019/04/09 18:27:36 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/04/11 11:39:06 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "lem_in.h"
|
||||
|
||||
// void lm_destroy_data(t_syntax *synt, t_holder *holder, t_lmdata *ldata)
|
||||
// {
|
||||
// // destroy and free memory
|
||||
// }
|
||||
|
||||
void lm_init_data(t_syntax *synt, t_holder *holder, t_lmdata *ldata)
|
||||
{
|
||||
synt->nb_state = 0;
|
||||
@@ -62,20 +57,24 @@ int lm_add_vertex(t_lmdata *ldata, char *raw, char flag,
|
||||
char **tab;
|
||||
t_node *new;
|
||||
|
||||
if (!(new = (t_node *)malloc(sizeof(t_node))))
|
||||
if (!(new = (t_node *)ft_memalloc(sizeof(t_node))))
|
||||
return (0);
|
||||
tab = ft_strsplit(raw, ' ');
|
||||
if (tab != NULL)
|
||||
{
|
||||
if (lm_check_room_before(tab, synt))
|
||||
{
|
||||
new->name = tab[0];
|
||||
if ((new->name = ft_strdup(tab[0])) == NULL)
|
||||
ft_del_words_tables(&tab);
|
||||
if (new->name == NULL)
|
||||
return (0);
|
||||
new->x = ft_atoi(tab[1]);
|
||||
new->y = ft_atoi(tab[2]);
|
||||
new->role = flag;
|
||||
new->ind = ldata->nb_nodes;
|
||||
new->next = NULL;
|
||||
lm_add_vertex_sub(ldata, new);
|
||||
ft_del_words_tables(&tab);
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
@@ -102,7 +101,7 @@ int lm_ext_conn(t_holder *holder, t_lmdata *data, char *raw)
|
||||
t_temp *temp;
|
||||
t_temp *new;
|
||||
|
||||
if (!(new = (t_temp *)malloc(sizeof(t_temp))))
|
||||
if (!(new = (t_temp *)ft_memalloc(sizeof(t_temp))))
|
||||
return (0);
|
||||
tab = ft_strsplit(raw, '-');
|
||||
if (tab != NULL)
|
||||
@@ -120,6 +119,7 @@ int lm_ext_conn(t_holder *holder, t_lmdata *data, char *raw)
|
||||
temp->next = new;
|
||||
}
|
||||
(holder->count)++;
|
||||
ft_del_words_tables(&tab);
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
|
||||
Reference in New Issue
Block a user