Compare commits
4 Commits
ba1cea020d
...
b22a1a5af7
Author | SHA1 | Date | |
---|---|---|---|
|
b22a1a5af7 | ||
|
a51c8ad81d | ||
|
6ad8cd2d95 | ||
|
9a386b315b |
3
Makefile
3
Makefile
@@ -6,7 +6,7 @@
|
|||||||
# By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ #
|
# By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2019/03/27 16:51:02 by tmaze #+# #+# #
|
# Created: 2019/03/27 16:51:02 by tmaze #+# #+# #
|
||||||
# Updated: 2019/04/24 18:00:14 by tmaze ### ########.fr #
|
# Updated: 2019/04/29 12:01:17 by mndhlovu ### ########.fr #
|
||||||
# #
|
# #
|
||||||
#******************************************************************************#
|
#******************************************************************************#
|
||||||
|
|
||||||
@@ -45,6 +45,7 @@ SRC = lm_parser.c \
|
|||||||
lm_graph_utils.c \
|
lm_graph_utils.c \
|
||||||
lm_parser_error_check.c \
|
lm_parser_error_check.c \
|
||||||
lm_utils_parser.c \
|
lm_utils_parser.c \
|
||||||
|
lm_utils_algo.c \
|
||||||
bfs.c \
|
bfs.c \
|
||||||
lst_ind.c \
|
lst_ind.c \
|
||||||
edmonds_karp.c \
|
edmonds_karp.c \
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/03/23 17:31:19 by tmaze #+# #+# */
|
/* Created: 2019/03/23 17:31:19 by tmaze #+# #+# */
|
||||||
/* Updated: 2019/04/24 18:10:12 by tmaze ### ########.fr */
|
/* Updated: 2019/04/29 12:14:34 by mndhlovu ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -96,7 +96,6 @@ typedef struct s_lmdata
|
|||||||
t_rdata *map;
|
t_rdata *map;
|
||||||
} t_lmdata;
|
} t_lmdata;
|
||||||
|
|
||||||
int lm_error_exit(void);
|
|
||||||
int lm_validate(t_syntax *synt, t_lmdata *lmdata);
|
int lm_validate(t_syntax *synt, t_lmdata *lmdata);
|
||||||
int lm_parser(t_syntax *synt, t_lmdata *ldata
|
int lm_parser(t_syntax *synt, t_lmdata *ldata
|
||||||
, t_holder *holder);
|
, t_holder *holder);
|
||||||
@@ -106,6 +105,8 @@ int lm_add_vertex(t_lmdata *ldata, char *raw, char flag
|
|||||||
, t_syntax *synt);
|
, t_syntax *synt);
|
||||||
int lm_ext_conn(t_holder *holder, t_lmdata *data
|
int lm_ext_conn(t_holder *holder, t_lmdata *data
|
||||||
, char *raw);
|
, char *raw);
|
||||||
|
int lm_init_src_dest(int *src, int *dest, t_lmdata *data
|
||||||
|
, char *raw);
|
||||||
int lm_find_index(t_lmdata *data, char *str);
|
int lm_find_index(t_lmdata *data, char *str);
|
||||||
|
|
||||||
int lm_get_value(char *line);
|
int lm_get_value(char *line);
|
||||||
@@ -148,4 +149,8 @@ void del_map(t_lmdata *data);
|
|||||||
int add_line_map(t_lmdata *data, char *line);
|
int add_line_map(t_lmdata *data, char *line);
|
||||||
void print_map(t_lmdata *data);
|
void print_map(t_lmdata *data);
|
||||||
|
|
||||||
|
t_node *get_node_role(t_lmdata *data, char role);
|
||||||
|
int get_nb_paths(t_ind **ret);
|
||||||
|
void get_nb_paths_max(t_lmdata *data, int start, int end);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
# By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ #
|
# By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2018/04/07 12:47:06 by tmaze #+# #+# #
|
# Created: 2018/04/07 12:47:06 by tmaze #+# #+# #
|
||||||
# Updated: 2019/04/22 12:11:07 by mndhlovu ### ########.fr #
|
# Updated: 2019/04/26 11:54:46 by mndhlovu ### ########.fr #
|
||||||
# #
|
# #
|
||||||
#******************************************************************************#
|
#******************************************************************************#
|
||||||
|
|
||||||
@@ -32,6 +32,7 @@ SRCS = ft_memalloc.c \
|
|||||||
ft_isascii.c \
|
ft_isascii.c \
|
||||||
ft_isprint.c \
|
ft_isprint.c \
|
||||||
ft_toupper.c \
|
ft_toupper.c \
|
||||||
|
ft_isnumeric.c \
|
||||||
ft_tolower.c \
|
ft_tolower.c \
|
||||||
ft_isupper.c \
|
ft_isupper.c \
|
||||||
ft_islower.c \
|
ft_islower.c \
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2018/04/08 00:12:36 by tmaze #+# #+# */
|
/* Created: 2018/04/08 00:12:36 by tmaze #+# #+# */
|
||||||
/* Updated: 2019/03/20 16:46:41 by tmaze ### ########.fr */
|
/* Updated: 2019/04/26 10:36:51 by mndhlovu ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -266,6 +266,7 @@ int ft_strncmp(const char *s1, const char *s2, size_t n);
|
|||||||
int ft_atoi(const char *str);
|
int ft_atoi(const char *str);
|
||||||
int ft_isalpha(int c);
|
int ft_isalpha(int c);
|
||||||
int ft_isdigit(int c);
|
int ft_isdigit(int c);
|
||||||
|
int ft_isnumeric(char *str);
|
||||||
int ft_isalnum(int c);
|
int ft_isalnum(int c);
|
||||||
int ft_isascii(int c);
|
int ft_isascii(int c);
|
||||||
int ft_isprint(int c);
|
int ft_isprint(int c);
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2018/04/04 11:33:35 by tmaze #+# #+# */
|
/* Created: 2018/04/04 11:33:35 by tmaze #+# #+# */
|
||||||
/* Updated: 2018/04/04 11:34:10 by tmaze ### ########.fr */
|
/* Updated: 2019/04/29 11:16:40 by mndhlovu ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
29
libft/srcs/ft_isnumeric.c
Normal file
29
libft/srcs/ft_isnumeric.c
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_isnumeric.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: mndhlovu <mndhlovu@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2019/04/26 10:17:04 by mndhlovu #+# #+# */
|
||||||
|
/* Updated: 2019/04/29 11:20:54 by mndhlovu ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
int ft_isnumeric(char *str)
|
||||||
|
{
|
||||||
|
int index;
|
||||||
|
|
||||||
|
index = 0;
|
||||||
|
if (str[index] == '-' || str[index] == '+')
|
||||||
|
index++;
|
||||||
|
while (str[index] != '\0')
|
||||||
|
{
|
||||||
|
if (!ft_isdigit(str[index]))
|
||||||
|
return (0);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
return (1);
|
||||||
|
}
|
14
map3
Normal file
14
map3
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
21
|
||||||
|
##start
|
||||||
|
start 0 0
|
||||||
|
##end
|
||||||
|
end 1 1
|
||||||
|
plop 2 2
|
||||||
|
lol 4 4
|
||||||
|
xd 3 3
|
||||||
|
start-plop
|
||||||
|
|
||||||
|
end-plop
|
||||||
|
start-lol
|
||||||
|
xd-lol
|
||||||
|
end-xd
|
@@ -6,7 +6,7 @@
|
|||||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/04/18 09:59:11 by tmaze #+# #+# */
|
/* Created: 2019/04/18 09:59:11 by tmaze #+# #+# */
|
||||||
/* Updated: 2019/04/21 16:11:56 by tmaze ### ########.fr */
|
/* Updated: 2019/04/26 12:49:36 by mndhlovu ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -109,11 +109,14 @@ t_ind **edmonds_karp(t_lmdata *data, int s_ind, int e_ind)
|
|||||||
scores[0] = 0;
|
scores[0] = 0;
|
||||||
nb_paths = 0;
|
nb_paths = 0;
|
||||||
i = 0;
|
i = 0;
|
||||||
|
ft_printf("data: %p\ndata->nb_nodes: %d\ndata->adj: %p\n\n", data, data->nb_nodes, data->adj);
|
||||||
while (i < data->nb_nodes)
|
while (i < data->nb_nodes)
|
||||||
tab[i++].old_visited = 0;
|
tab[i++].old_visited = 0;
|
||||||
bfs(data, tab, s_ind, e_ind);
|
bfs(data, tab, s_ind, e_ind);
|
||||||
|
ft_printf("tab[e_ind].parent: %d\n", tab[e_ind].parent);
|
||||||
while (tab[e_ind].parent != -1)
|
while (tab[e_ind].parent != -1)
|
||||||
{
|
{
|
||||||
|
ft_printf("new path\n");
|
||||||
nb_paths++;
|
nb_paths++;
|
||||||
update_weights(data, tab, s_ind, e_ind);
|
update_weights(data, tab, s_ind, e_ind);
|
||||||
ret[1] = resolve_paths(data, nb_paths, s_ind, e_ind);
|
ret[1] = resolve_paths(data, nb_paths, s_ind, e_ind);
|
||||||
|
@@ -6,65 +6,23 @@
|
|||||||
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/03/25 06:31:05 by mndhlovu #+# #+# */
|
/* Created: 2019/03/25 06:31:05 by mndhlovu #+# #+# */
|
||||||
/* Updated: 2019/04/24 18:23:42 by tmaze ### ########.fr */
|
/* Updated: 2019/04/29 12:54:07 by tmaze ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "lem_in.h"
|
#include "lem_in.h"
|
||||||
|
|
||||||
static t_node *get_node_role(t_lmdata *data, char role)
|
|
||||||
{
|
|
||||||
t_node *it;
|
|
||||||
|
|
||||||
it = data->nodes_data;
|
|
||||||
while (it)
|
|
||||||
{
|
|
||||||
if (it->role == role)
|
|
||||||
return (it);
|
|
||||||
it = it->next;
|
|
||||||
}
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_nb_paths(t_ind **ret)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
while (ret[i])
|
|
||||||
i++;
|
|
||||||
return (i);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void get_nb_paths_max(t_lmdata *data, int start, int end)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int j;
|
|
||||||
t_ind *it;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
j = 0;
|
|
||||||
it = data->adj[start];
|
|
||||||
while (it && ++i)
|
|
||||||
it = it->next;
|
|
||||||
it = data->adj[end];
|
|
||||||
while (it && ++j)
|
|
||||||
it= it->next;
|
|
||||||
data->nb_paths_max = (i > j) ? j : i;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int lem_in(t_syntax *synt, t_holder *holder,
|
static int lem_in(t_syntax *synt, t_holder *holder,
|
||||||
t_lmdata *lmdata, t_ind ***ret)
|
t_lmdata *lmdata, t_ind ***ret)
|
||||||
{
|
{
|
||||||
if (!(lm_parser(synt, lmdata, holder)))
|
lm_parser(synt, lmdata, holder);
|
||||||
|
if (!lm_verify_cmd(synt, holder, lmdata))
|
||||||
return (0);
|
return (0);
|
||||||
if (!(lm_verify_cmd(synt, holder, lmdata)))
|
|
||||||
return (0);
|
|
||||||
print_map(lmdata);
|
|
||||||
if (!lst_indinit(lmdata))
|
if (!lst_indinit(lmdata))
|
||||||
return (0);
|
return (0);
|
||||||
if (!(lm_adj_parser(lmdata, holder)))
|
if ((lm_adj_parser(lmdata, holder) == 0))
|
||||||
return (0);
|
return (0);
|
||||||
|
print_map(lmdata);
|
||||||
lm_clear_unv(holder);
|
lm_clear_unv(holder);
|
||||||
get_nb_paths_max(lmdata, get_node_role(lmdata, 's')->ind
|
get_nb_paths_max(lmdata, get_node_role(lmdata, 's')->ind
|
||||||
, get_node_role(lmdata, 'e')->ind);
|
, get_node_role(lmdata, 'e')->ind);
|
||||||
@@ -77,7 +35,7 @@ static int lem_in(t_syntax *synt, t_holder *holder,
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int lm_error_exit(void)
|
static int lm_error_exit(void)
|
||||||
{
|
{
|
||||||
ft_putendl_fd("ERROR", 2);
|
ft_putendl_fd("ERROR", 2);
|
||||||
return (1);
|
return (1);
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
/* By: mndhlovu <mndhlovu@student.42.fr> +#+ +:+ +#+ */
|
/* By: mndhlovu <mndhlovu@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/04/22 08:55:30 by mndhlovu #+# #+# */
|
/* Created: 2019/04/22 08:55:30 by mndhlovu #+# #+# */
|
||||||
/* Updated: 2019/04/24 09:49:38 by tmaze ### ########.fr */
|
/* Updated: 2019/04/29 12:06:41 by mndhlovu ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -16,14 +16,12 @@ int lm_check_room_before(char **tab, t_syntax *synt)
|
|||||||
{
|
{
|
||||||
if (tab[0] != NULL && tab[1] != NULL && tab[2] != NULL)
|
if (tab[0] != NULL && tab[1] != NULL && tab[2] != NULL)
|
||||||
{
|
{
|
||||||
if (!lm_validate_rooms(tab[0], tab[1], tab[2]))
|
if (lm_validate_rooms(tab[0], tab[1], tab[2]))
|
||||||
{
|
return (1);
|
||||||
|
}
|
||||||
synt->v_error = 1;
|
synt->v_error = 1;
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int lm_check_forbiden_chars(char *line, int flag)
|
int lm_check_forbiden_chars(char *line, int flag)
|
||||||
{
|
{
|
||||||
@@ -34,17 +32,14 @@ int lm_check_forbiden_chars(char *line, int flag)
|
|||||||
{
|
{
|
||||||
dash = ft_strchr(line, '-');
|
dash = ft_strchr(line, '-');
|
||||||
hash = ft_strchr(line, '#');
|
hash = ft_strchr(line, '#');
|
||||||
if (flag == 0 && dash == NULL
|
if (flag == 0 && dash == NULL && hash == NULL)
|
||||||
&& hash == NULL)
|
|
||||||
return (1);
|
return (1);
|
||||||
if (flag == 1 && dash == NULL
|
if (flag == 1 && dash == NULL && hash != NULL)
|
||||||
&& hash != NULL)
|
|
||||||
return (1);
|
return (1);
|
||||||
if (flag == 2 && dash == NULL
|
if (flag == 2 && dash == NULL
|
||||||
&& (hash == NULL || (hash != NULL && line[1] != '#')))
|
&& (hash == NULL || (hash != NULL && line[1] != '#')))
|
||||||
return (1);
|
return (1);
|
||||||
if (flag == 3 && dash != NULL
|
if (flag == 3 && dash != NULL && hash == NULL)
|
||||||
&& hash == NULL)
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
@@ -66,11 +61,21 @@ void lm_clear_unv(t_holder *holder)
|
|||||||
holder->data = NULL;
|
holder->data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int lm_verify_cmd(t_syntax *synt, t_holder *holder, t_lmdata *data)
|
int lm_verify_links(t_holder *data, t_syntax *synt)
|
||||||
{
|
{
|
||||||
if (synt->s_cmd && synt->e_cmd && !synt->v_error
|
if (!synt->l_error || (synt->l_error && data->count > 0))
|
||||||
&& !synt->l_error && !synt->e_error && !synt->s_error
|
return (1);
|
||||||
&& synt->nb_state && (holder->count > 0)
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int lm_verify_cmd(t_syntax *synt, t_holder *holder
|
||||||
|
, t_lmdata *data)
|
||||||
|
{
|
||||||
|
if (synt->s_cmd && synt->e_cmd
|
||||||
|
&& !synt->e_error && !synt->s_error
|
||||||
|
&& !synt->v_error
|
||||||
|
&& synt->nb_state
|
||||||
|
&& lm_verify_links(holder, synt)
|
||||||
&& (data->nb_nodes > 0))
|
&& (data->nb_nodes > 0))
|
||||||
return (1);
|
return (1);
|
||||||
lm_clear_unv(holder);
|
lm_clear_unv(holder);
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/04/05 06:35:40 by mndhlovu #+# #+# */
|
/* Created: 2019/04/05 06:35:40 by mndhlovu #+# #+# */
|
||||||
/* Updated: 2019/04/23 11:01:37 by tmaze ### ########.fr */
|
/* Updated: 2019/04/29 12:06:18 by mndhlovu ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/03/29 07:17:06 by mndhlovu #+# #+# */
|
/* Created: 2019/03/29 07:17:06 by mndhlovu #+# #+# */
|
||||||
/* Updated: 2019/04/24 09:43:02 by tmaze ### ########.fr */
|
/* Updated: 2019/04/29 12:05:52 by mndhlovu ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
static int is_link_in(t_lmdata *data, int src, int dest)
|
static int is_link_in(t_lmdata *data, int src, int dest)
|
||||||
{
|
{
|
||||||
t_ind *it;
|
t_ind *it;
|
||||||
|
|
||||||
if (src < data->nb_nodes)
|
if (src < data->nb_nodes)
|
||||||
{
|
{
|
||||||
it = data->adj[src];
|
it = data->adj[src];
|
||||||
@@ -32,16 +33,13 @@ int lm_adj_parser(t_lmdata *lmdata, t_holder *holder)
|
|||||||
{
|
{
|
||||||
t_temp *data;
|
t_temp *data;
|
||||||
|
|
||||||
ft_printf("=== lm_adj_parser ===\nholder: %p\n\n", holder);
|
|
||||||
if (holder != NULL)
|
if (holder != NULL)
|
||||||
{
|
{
|
||||||
data = holder->data;
|
data = holder->data;
|
||||||
ft_printf("data: %p\n\n", data);
|
|
||||||
if (data != NULL)
|
if (data != NULL)
|
||||||
{
|
{
|
||||||
while (data)
|
while (data)
|
||||||
{
|
{
|
||||||
ft_printf("=== link ===\nis_lin_in: %d\n\n", is_link_in(lmdata, data->src_ind, data->dest_ind));
|
|
||||||
if (!is_link_in(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);
|
lst_indadd_link(lmdata, data->src_ind, data->dest_ind);
|
||||||
data = data->next;
|
data = data->next;
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/03/23 17:43:34 by tmaze #+# #+# */
|
/* Created: 2019/03/23 17:43:34 by tmaze #+# #+# */
|
||||||
/* Updated: 2019/04/22 12:44:00 by mndhlovu ### ########.fr */
|
/* Updated: 2019/04/29 12:08:36 by mndhlovu ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -18,3 +18,32 @@ void lm_initdata(t_lmdata *data)
|
|||||||
data->nodes_data = NULL;
|
data->nodes_data = NULL;
|
||||||
data->adj = NULL;
|
data->adj = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int lm_init_src_dest(int *src, int *dest, t_lmdata *data
|
||||||
|
, char *raw)
|
||||||
|
{
|
||||||
|
int s;
|
||||||
|
int d;
|
||||||
|
char **tab;
|
||||||
|
|
||||||
|
if (raw != NULL)
|
||||||
|
{
|
||||||
|
tab = ft_strsplit(raw, '-');
|
||||||
|
if (tab != NULL)
|
||||||
|
{
|
||||||
|
s = lm_find_index(data, tab[0]);
|
||||||
|
d = lm_find_index(data, tab[1]);
|
||||||
|
if (s == -1 || d == -1)
|
||||||
|
{
|
||||||
|
ft_del_words_tables(&tab);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
*src = s;
|
||||||
|
*dest = d;
|
||||||
|
ft_del_words_tables(&tab);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ft_del_words_tables(&tab);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/03/25 06:31:37 by mndhlovu #+# #+# */
|
/* Created: 2019/03/25 06:31:37 by mndhlovu #+# #+# */
|
||||||
/* Updated: 2019/04/24 18:03:58 by tmaze ### ########.fr */
|
/* Updated: 2019/04/29 12:07:09 by mndhlovu ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -98,24 +98,15 @@ int lm_find_index(t_lmdata *data, char *str)
|
|||||||
|
|
||||||
int lm_ext_conn(t_holder *holder, t_lmdata *data, char *raw)
|
int lm_ext_conn(t_holder *holder, t_lmdata *data, char *raw)
|
||||||
{
|
{
|
||||||
char **tab;
|
|
||||||
t_temp *temp;
|
t_temp *temp;
|
||||||
|
t_temp *new;
|
||||||
int src;
|
int src;
|
||||||
int dest;
|
int dest;
|
||||||
t_temp *new;
|
|
||||||
|
|
||||||
if (!(new = (t_temp *)ft_memalloc(sizeof(t_temp))))
|
if (!(new = (t_temp *)ft_memalloc(sizeof(t_temp))))
|
||||||
return (0);
|
return (0);
|
||||||
tab = ft_strsplit(raw, '-');
|
if (lm_init_src_dest(&src, &dest, data, raw))
|
||||||
if (tab != NULL)
|
|
||||||
{
|
{
|
||||||
src = lm_find_index(data, tab[0]);
|
|
||||||
dest = lm_find_index(data, tab[1]);
|
|
||||||
if (src == -1 || dest == -1)
|
|
||||||
{
|
|
||||||
ft_del_words_tables(&tab);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
new->src_ind = src;
|
new->src_ind = src;
|
||||||
new->dest_ind = dest;
|
new->dest_ind = dest;
|
||||||
new->next = NULL;
|
new->next = NULL;
|
||||||
@@ -129,7 +120,6 @@ int lm_ext_conn(t_holder *holder, t_lmdata *data, char *raw)
|
|||||||
temp->next = new;
|
temp->next = new;
|
||||||
}
|
}
|
||||||
(holder->count)++;
|
(holder->count)++;
|
||||||
ft_del_words_tables(&tab);
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
|
@@ -6,18 +6,17 @@
|
|||||||
/* By: mndhlovu <mndhlovu@student.42.fr> +#+ +:+ +#+ */
|
/* By: mndhlovu <mndhlovu@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/04/20 15:24:51 by mndhlovu #+# #+# */
|
/* Created: 2019/04/20 15:24:51 by mndhlovu #+# #+# */
|
||||||
/* Updated: 2019/04/24 09:45:04 by tmaze ### ########.fr */
|
/* Updated: 2019/04/29 13:07:10 by tmaze ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "lem_in.h"
|
#include "lem_in.h"
|
||||||
|
|
||||||
void lm_locate_cd(int index, t_syntax *synt, char *line)
|
static void lm_locate_cd(int index, t_syntax *synt, char *line)
|
||||||
{
|
{
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
tmp = ft_strchr(line, '#');
|
tmp = ft_strchr(line, '#');
|
||||||
ft_printf("Bingo 1\n");
|
|
||||||
if ((!synt->s_cmd || !synt->e_cmd)
|
if ((!synt->s_cmd || !synt->e_cmd)
|
||||||
&& (tmp != NULL && line[1] == '#'
|
&& (tmp != NULL && line[1] == '#'
|
||||||
&& lm_check_forbiden_chars(line, 1)))
|
&& lm_check_forbiden_chars(line, 1)))
|
||||||
@@ -26,7 +25,6 @@ void lm_locate_cd(int index, t_syntax *synt, char *line)
|
|||||||
{
|
{
|
||||||
if (ft_strcmp(line, "##start") == 0)
|
if (ft_strcmp(line, "##start") == 0)
|
||||||
{
|
{
|
||||||
ft_printf("Bingo 2\n");
|
|
||||||
synt->s_cmd = 1;
|
synt->s_cmd = 1;
|
||||||
synt->s_pos = index;
|
synt->s_pos = index;
|
||||||
}
|
}
|
||||||
@@ -35,7 +33,6 @@ void lm_locate_cd(int index, t_syntax *synt, char *line)
|
|||||||
{
|
{
|
||||||
if (ft_strcmp(line, "##end") == 0)
|
if (ft_strcmp(line, "##end") == 0)
|
||||||
{
|
{
|
||||||
ft_printf("Bingo 3\n");
|
|
||||||
synt->e_cmd = 1;
|
synt->e_cmd = 1;
|
||||||
synt->e_pos = index;
|
synt->e_pos = index;
|
||||||
}
|
}
|
||||||
@@ -43,16 +40,16 @@ void lm_locate_cd(int index, t_syntax *synt, char *line)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int lm_get_ant_(int counter, t_lmdata *ldata, t_syntax *synt, char *line)
|
static int lm_get_ant_(int counter, t_lmdata *ldata
|
||||||
|
, t_syntax *synt, char *line)
|
||||||
{
|
{
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
if (counter == 0 && lm_check_forbiden_chars(line, 0))
|
if (counter == 0 && lm_check_forbiden_chars(line, 0))
|
||||||
{
|
{
|
||||||
value = lm_get_value(line);
|
value = lm_get_value(line);
|
||||||
if (value != -1)
|
if (value > 0)
|
||||||
{
|
{
|
||||||
ft_printf("Bingo 4 %d\n", value);
|
|
||||||
ldata->nbants = value;
|
ldata->nbants = value;
|
||||||
synt->nb_state = 1;
|
synt->nb_state = 1;
|
||||||
return (1);
|
return (1);
|
||||||
@@ -62,14 +59,12 @@ int lm_get_ant_(int counter, t_lmdata *ldata, t_syntax *synt, char *line)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lm_get_vertices(int count, t_syntax *synt,
|
static int lm_get_vertices(int count, t_syntax *synt
|
||||||
t_lmdata *data, t_holder *holder, char *line)
|
, t_lmdata *data, t_holder *holder, char *line)
|
||||||
{
|
{
|
||||||
ft_printf("Bingo 5\n");
|
|
||||||
lm_get_cmd_vert(count, synt, data, line);
|
lm_get_cmd_vert(count, synt, data, line);
|
||||||
if (!synt->s_error && !synt->e_error)
|
if (!synt->s_error && !synt->e_error)
|
||||||
{
|
{
|
||||||
ft_printf("Bingo 6 %s\n", line);
|
|
||||||
lm_get_vert_link(count, synt, data, holder, line);
|
lm_get_vert_link(count, synt, data, holder, line);
|
||||||
if (!synt->v_error && !synt->l_error)
|
if (!synt->v_error && !synt->l_error)
|
||||||
return (1);
|
return (1);
|
||||||
@@ -77,32 +72,24 @@ static int lm_get_vertices(int count, t_syntax *synt,
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int lm_parser(t_syntax *synt, t_lmdata *ldata,
|
int lm_parser(t_syntax *synt
|
||||||
t_holder *holder)
|
, t_lmdata *ldata, t_holder *holder)
|
||||||
{
|
{
|
||||||
char *raw;
|
char *raw;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
index = 0;
|
index = 0;
|
||||||
while (ft_getline(&raw) > 0)
|
while (ft_getline(&raw) > 0 && raw[0] != '\0')
|
||||||
{
|
{
|
||||||
ft_printf("%s\n", raw);
|
if ((add_line_map(ldata, raw)))
|
||||||
if (!(lm_get_ant_(index, ldata, synt, raw)) && index == 0)
|
return (0);
|
||||||
{
|
if (!(lm_get_ant_(index, ldata, synt, raw)) && index == 0)
|
||||||
ft_printf("banane\n");
|
|
||||||
ft_strdel(&raw);
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
|
||||||
lm_locate_cd(index, synt, raw);
|
lm_locate_cd(index, synt, raw);
|
||||||
if (!(lm_get_vertices(index, synt, ldata, holder, raw)))
|
if (!(lm_get_vertices(index, synt, ldata, holder, raw)))
|
||||||
{
|
|
||||||
ft_strdel(&raw);
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
|
||||||
ft_strdel(&raw);
|
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
ft_strdel(&raw);
|
ft_strdel(&raw);
|
||||||
ft_putchar('\n');
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
@@ -6,13 +6,13 @@
|
|||||||
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/04/08 06:42:37 by mndhlovu #+# #+# */
|
/* Created: 2019/04/08 06:42:37 by mndhlovu #+# #+# */
|
||||||
/* Updated: 2019/04/20 13:29:12 by mndhlovu ### ########.fr */
|
/* Updated: 2019/04/29 12:06:08 by mndhlovu ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "lem_in.h"
|
#include "lem_in.h"
|
||||||
|
|
||||||
int lm_chk_format_nbr(char *raw)
|
static int lm_chk_format_nbr(char *raw)
|
||||||
{
|
{
|
||||||
while (*raw)
|
while (*raw)
|
||||||
{
|
{
|
||||||
@@ -25,14 +25,14 @@ int lm_chk_format_nbr(char *raw)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int lm_check_max(char *raw)
|
static int lm_check_max(char *raw)
|
||||||
{
|
{
|
||||||
if (ft_atoi(raw) < INT_MIN || ft_atoi(raw) > INT_MAX)
|
if (ft_atoi(raw) < INT_MIN || ft_atoi(raw) > INT_MAX)
|
||||||
return (-1);
|
return (-1);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int lm_validate_name(char *name)
|
static int lm_validate_name(char *name)
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
@@ -51,25 +51,26 @@ int lm_validate_name(char *name)
|
|||||||
int lm_validate_rooms(char *name, char *x, char *y)
|
int lm_validate_rooms(char *name, char *x, char *y)
|
||||||
{
|
{
|
||||||
if (lm_validate_name(name) == -1)
|
if (lm_validate_name(name) == -1)
|
||||||
return (-1);
|
|
||||||
if (lm_chk_format_nbr(x) == -1 ||
|
|
||||||
lm_check_max(x) == -1 || (ft_atoi(x) > 0 &&
|
|
||||||
(ft_atoi(x) == 0)) ||
|
|
||||||
ft_strlen(x) > 19)
|
|
||||||
return (0);
|
return (0);
|
||||||
if (lm_chk_format_nbr(y) == -1 ||
|
if (lm_chk_format_nbr(x) == -1
|
||||||
lm_check_max(y) == -1 || (ft_atoi(y) > 0 &&
|
|| lm_check_max(x) == -1
|
||||||
(ft_atoi(y) == 0)) ||
|
|| (ft_atoi(x) > 0 && (ft_atoi(x) == 0))
|
||||||
ft_strlen(y) > 19)
|
|| ft_strlen(x) > 19)
|
||||||
|
return (0);
|
||||||
|
if (lm_chk_format_nbr(y) == -1
|
||||||
|
|| lm_check_max(y) == -1
|
||||||
|
|| (ft_atoi(y) > 0 && (ft_atoi(y) == 0))
|
||||||
|
|| ft_strlen(y) > 19)
|
||||||
return (0);
|
return (0);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int lm_error_nbr(char *raw)
|
int lm_error_nbr(char *raw)
|
||||||
{
|
{
|
||||||
if (lm_chk_format_nbr(raw) == -1 || lm_check_max(raw) == -1 ||
|
if (lm_chk_format_nbr(raw) == -1
|
||||||
(ft_atoi(raw) > 0 && (ft_atoi(raw) == 0)) ||
|
|| lm_check_max(raw) == -1
|
||||||
ft_strlen(raw) > 19)
|
|| (ft_atoi(raw) > 0 && (ft_atoi(raw) == 0))
|
||||||
|
|| ft_strlen(raw) > 19)
|
||||||
return (-1);
|
return (-1);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
54
srcs/lm_utils_algo.c
Normal file
54
srcs/lm_utils_algo.c
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* lm_utils_algo.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: mndhlovu <mndhlovu@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2019/04/29 11:50:04 by mndhlovu #+# #+# */
|
||||||
|
/* Updated: 2019/04/29 12:10:09 by mndhlovu ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "lem_in.h"
|
||||||
|
|
||||||
|
t_node *get_node_role(t_lmdata *data, char role)
|
||||||
|
{
|
||||||
|
t_node *it;
|
||||||
|
|
||||||
|
it = data->nodes_data;
|
||||||
|
while (it)
|
||||||
|
{
|
||||||
|
if (it->role == role)
|
||||||
|
return (it);
|
||||||
|
it = it->next;
|
||||||
|
}
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_nb_paths(t_ind **ret)
|
||||||
|
{
|
||||||
|
int index;
|
||||||
|
|
||||||
|
index = 0;
|
||||||
|
while (ret[index])
|
||||||
|
index++;
|
||||||
|
return (index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void get_nb_paths_max(t_lmdata *data, int start, int end)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int j;
|
||||||
|
t_ind *it;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
j = 0;
|
||||||
|
it = data->adj[start];
|
||||||
|
while (it && ++i)
|
||||||
|
it = it->next;
|
||||||
|
it = data->adj[end];
|
||||||
|
while (it && ++j)
|
||||||
|
it = it->next;
|
||||||
|
data->nb_paths_max = (i > j) ? j : i;
|
||||||
|
}
|
@@ -6,30 +6,32 @@
|
|||||||
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/04/04 09:24:45 by mndhlovu #+# #+# */
|
/* Created: 2019/04/04 09:24:45 by mndhlovu #+# #+# */
|
||||||
/* Updated: 2019/04/24 09:47:29 by tmaze ### ########.fr */
|
/* Updated: 2019/04/29 12:05:40 by mndhlovu ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "lem_in.h"
|
#include "lem_in.h"
|
||||||
|
|
||||||
|
static int lm_check_ant_no(char *line)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
|
||||||
|
len = ft_strlen(line);
|
||||||
|
if (len > 0)
|
||||||
|
{
|
||||||
|
if (len == 1 && ft_isdigit(*line))
|
||||||
|
return (*line - '0');
|
||||||
|
else if (len > 1 && len < 19 && ft_isnumeric(line))
|
||||||
|
return (ft_atoi(line));
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
int lm_get_value(char *line)
|
int lm_get_value(char *line)
|
||||||
{
|
{
|
||||||
int index;
|
|
||||||
|
|
||||||
if (line != NULL)
|
if (line != NULL)
|
||||||
{
|
return (lm_check_ant_no(line));
|
||||||
index = ft_atoi(line);
|
return (0);
|
||||||
if (index > INT_MIN && index < INT_MAX)
|
|
||||||
{
|
|
||||||
if (index > 0)
|
|
||||||
return (index);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lm_get_cmd_vert(int count, t_syntax *synt
|
void lm_get_cmd_vert(int count, t_syntax *synt
|
||||||
@@ -44,7 +46,7 @@ void lm_get_cmd_vert(int count, t_syntax *synt
|
|||||||
{
|
{
|
||||||
synt->s_vert = count;
|
synt->s_vert = count;
|
||||||
if (!(lm_add_vertex(ldata, line, 's', synt)))
|
if (!(lm_add_vertex(ldata, line, 's', synt)))
|
||||||
synt->e_error = 1;
|
synt->s_error = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (synt->e_pos == count - 1)
|
if (synt->e_pos == count - 1)
|
||||||
@@ -54,32 +56,27 @@ void lm_get_cmd_vert(int count, t_syntax *synt
|
|||||||
{
|
{
|
||||||
synt->e_vert = count;
|
synt->e_vert = count;
|
||||||
if (!(lm_add_vertex(ldata, line, 'e', synt)))
|
if (!(lm_add_vertex(ldata, line, 'e', synt)))
|
||||||
synt->s_error = 1;
|
synt->e_error = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void lm_get_vert_link(int count, t_syntax *synt, t_lmdata *ldata
|
void lm_get_vert_link(int count, t_syntax *synt
|
||||||
, t_holder *holder, char *line)
|
, t_lmdata *ldata, t_holder *holder, char *line)
|
||||||
{
|
{
|
||||||
if (count > 0 && (count != synt->s_vert && count != synt->e_vert)
|
if (count > 0 && (count != synt->s_vert && count != synt->e_vert)
|
||||||
&& (count != synt->s_pos && count != synt->e_pos))
|
&& (count != synt->s_pos
|
||||||
|
&& count != synt->e_pos && line != NULL))
|
||||||
{
|
{
|
||||||
if (lm_check_forbiden_chars(line, 0))
|
if (lm_check_forbiden_chars(line, 0))
|
||||||
{
|
{
|
||||||
ft_printf("Bingo 7 %s\n", line);
|
|
||||||
if (!(lm_add_vertex(ldata, line, 'v', synt)))
|
if (!(lm_add_vertex(ldata, line, 'v', synt)))
|
||||||
{
|
|
||||||
synt->v_error = 1;
|
synt->v_error = 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (lm_check_forbiden_chars(line, 3))
|
if (lm_check_forbiden_chars(line, 3))
|
||||||
{
|
{
|
||||||
if (!(lm_ext_conn(holder, ldata, line)))
|
if (!(lm_ext_conn(holder, ldata, line)))
|
||||||
{
|
|
||||||
synt->l_error = 1;
|
synt->l_error = 1;
|
||||||
return ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,11 +6,12 @@
|
|||||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/04/24 17:35:29 by tmaze #+# #+# */
|
/* Created: 2019/04/24 17:35:29 by tmaze #+# #+# */
|
||||||
/* Updated: 2019/04/26 11:36:27 by mndhlovu ### ########.fr */
|
/* Updated: 2019/04/29 13:05:56 by tmaze ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "lem_in.h"
|
#include "lem_in.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
void del_map(t_lmdata *data)
|
void del_map(t_lmdata *data)
|
||||||
{
|
{
|
||||||
@@ -18,9 +19,9 @@ void del_map(t_lmdata *data)
|
|||||||
|
|
||||||
while (data->map)
|
while (data->map)
|
||||||
{
|
{
|
||||||
ft_strdel(&(data->map->line));
|
|
||||||
tmp = data->map;
|
tmp = data->map;
|
||||||
data->map = data->map->next;
|
data->map = data->map->next;
|
||||||
|
ft_strdel(&(tmp->line));
|
||||||
ft_memdel((void**)&tmp);
|
ft_memdel((void**)&tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user