aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRudy Bousset <rbousset@z2r5p6.le-101.fr>2020-02-02 17:05:54 +0100
committerRudy Bousset <rbousset@z2r5p6.le-101.fr>2020-02-02 17:05:54 +0100
commit8d7f65c1c04f7124f1a34062be377fdbe721c46a (patch)
tree36ef68573148ba58843608a499504138cca3595d /src
parentRemoved whitespace (diff)
download42-cub3d-8d7f65c1c04f7124f1a34062be377fdbe721c46a.tar.gz
42-cub3d-8d7f65c1c04f7124f1a34062be377fdbe721c46a.tar.bz2
42-cub3d-8d7f65c1c04f7124f1a34062be377fdbe721c46a.tar.xz
42-cub3d-8d7f65c1c04f7124f1a34062be377fdbe721c46a.tar.zst
42-cub3d-8d7f65c1c04f7124f1a34062be377fdbe721c46a.zip
Correct ft_memdel
Diffstat (limited to 'src')
-rw-r--r--src/ft_exit.c19
-rw-r--r--src/ft_free_words.c4
-rw-r--r--src/ft_get_map.c16
-rw-r--r--src/ft_get_sprite.c2
-rw-r--r--src/ft_get_tex.c8
-rw-r--r--src/ft_init_lists.c2
-rw-r--r--src/ft_init_winlx.c4
-rw-r--r--src/ft_parse_map.c8
-rw-r--r--src/main.c6
9 files changed, 36 insertions, 33 deletions
diff --git a/src/ft_exit.c b/src/ft_exit.c
index 8bd8ac0..6631c34 100644
--- a/src/ft_exit.c
+++ b/src/ft_exit.c
@@ -8,17 +8,18 @@
static void
ft_free_lists(t_cub *clist)
{
- ft_memdel(clist->no_tex_path);
- ft_memdel(clist->so_tex_path);
- ft_memdel(clist->ea_tex_path);
- ft_memdel(clist->we_tex_path);
- ft_memdel(clist->sprite_path);
+ ft_memdel((void**)&clist->no_tex_path);
+ ft_memdel((void**)&clist->so_tex_path);
+ ft_memdel((void**)&clist->ea_tex_path);
+ ft_memdel((void**)&clist->we_tex_path);
+ ft_memdel((void**)&clist->sprite_path);
+ ft_memdel((void**)&clist->mapl);
ft_free_words(clist->map);
if (!clist->wlist->inited)
- ft_memdel(clist->wlist->winptr);
- ft_memdel(clist->wlist->wlx);
- ft_memdel(clist->wlist);
- ft_memdel(clist);
+ ft_memdel((void**)&clist->wlist->winptr);
+ ft_memdel((void**)&clist->wlist->wlx);
+ ft_memdel((void**)&clist->wlist);
+ ft_memdel((void**)&clist);
}
int
diff --git a/src/ft_free_words.c b/src/ft_free_words.c
index 3231791..1029710 100644
--- a/src/ft_free_words.c
+++ b/src/ft_free_words.c
@@ -8,8 +8,8 @@ ft_free_words(char **words)
i = 0;
while (words[i])
{
- ft_memdel(words[i]);
+ ft_memdel((void**)&words[i]);
i++;
}
- ft_memdel(words);
+ ft_memdel((void**)&words);
}
diff --git a/src/ft_get_map.c b/src/ft_get_map.c
index 3844f41..adedf7c 100644
--- a/src/ft_get_map.c
+++ b/src/ft_get_map.c
@@ -40,22 +40,22 @@ ft_get_map_first_line(char *line, t_cub *clist)
{
if (!line[0])
{
- ft_memdel(line);
+ ft_memdel((void**)&line);
return (-1);
}
clist->map_w = ft_get_line_len(line);
if (ft_check_map_line(line, 1, clist) < 0)
{
- ft_memdel(line);
+ ft_memdel((void**)&line);
return (-1);
}
- clist->mapl = NULL;
+ ft_memdel((void**)&clist->mapl);
if (ft_cat_mapl(line, 0, clist) < 0)
{
- ft_memdel(line);
+ ft_memdel((void**)&line);
return (-1);
}
- ft_memdel(line);
+ ft_memdel((void**)&line);
return (1);
}
@@ -75,15 +75,15 @@ ft_get_map_core(int fd, t_cub *clist)
if (!line[0] || ft_check_map_line(line, 0, clist) < 0
|| ft_cat_mapl(line, i, clist) < 0)
{
- ft_memdel(line);
+ ft_memdel((void**)&line);
return (-1);
}
- ft_memdel(line);
+ ft_memdel((void**)&line);
i++;
}
clist->mapl[((clist->map_w + 1) * i) - 1] = '\0';
ft_free_words(clist->map);
clist->map = ft_split(clist->mapl, '\n');
- ft_memdel(clist->mapl);
+ ft_memdel((void**)&clist->mapl);
return (0);
}
diff --git a/src/ft_get_sprite.c b/src/ft_get_sprite.c
index b412442..b588df7 100644
--- a/src/ft_get_sprite.c
+++ b/src/ft_get_sprite.c
@@ -6,7 +6,7 @@ ft_get_sprite(char **words, t_cub *clist)
{
if (!(*words) || !words[1] || words[2])
return (-1);
- ft_memdel(clist->sprite_path);
+ ft_memdel((void**)&clist->sprite_path);
if (!(clist->sprite_path = ft_strdup(*(words + 1))))
return (-1);
return (0);
diff --git a/src/ft_get_tex.c b/src/ft_get_tex.c
index 3c0f305..5b8e24e 100644
--- a/src/ft_get_tex.c
+++ b/src/ft_get_tex.c
@@ -7,7 +7,7 @@ ft_get_tex_no(char **words, t_cub *clist)
{
if (!(*words) || !(*(words + 1)) || (*(words + 2)))
return (-1);
- ft_memdel(clist->no_tex_path);
+ ft_memdel((void**)&clist->no_tex_path);
if (!(clist->no_tex_path = ft_strdup(*(words + 1))))
return (-1);
return (0);
@@ -18,7 +18,7 @@ ft_get_tex_so(char **words, t_cub *clist)
{
if (!(*words) || !(*(words + 1)) || (*(words + 2)))
return (-1);
- ft_memdel(clist->so_tex_path);
+ ft_memdel((void**)&clist->so_tex_path);
if (!(clist->so_tex_path = ft_strdup(*(words + 1))))
return (-1);
return (0);
@@ -29,7 +29,7 @@ ft_get_tex_ea(char **words, t_cub *clist)
{
if (!(*words) || !(*(words + 1)) || (*(words + 2)))
return (-1);
- ft_memdel(clist->ea_tex_path);
+ ft_memdel((void**)&clist->ea_tex_path);
if (!(clist->ea_tex_path = ft_strdup(*(words + 1))))
return (-1);
return (0);
@@ -40,7 +40,7 @@ ft_get_tex_we(char **words, t_cub *clist)
{
if (!(*words) || !(*(words + 1)) || (*(words + 2)))
return (-1);
- ft_memdel(clist->we_tex_path);
+ ft_memdel((void**)&clist->we_tex_path);
if (!(clist->we_tex_path = ft_strdup(*(words + 1))))
return (-1);
return (0);
diff --git a/src/ft_init_lists.c b/src/ft_init_lists.c
index 63357ec..285dbd8 100644
--- a/src/ft_init_lists.c
+++ b/src/ft_init_lists.c
@@ -32,6 +32,7 @@ t_cub
!(clist->ea_tex_path = (char*)ft_calloc(1, sizeof(char))) ||
!(clist->we_tex_path = (char*)ft_calloc(1, sizeof(char))) ||
!(clist->sprite_path = (char*)ft_calloc(1, sizeof(char))) ||
+ !(clist->mapl = (char*)ft_calloc(1, sizeof(char))) ||
!(clist->map = (char**)ft_calloc(2, sizeof(char*))) ||
!(clist->map[0] = (char*)ft_calloc(1, sizeof(char))))
return (NULL);
@@ -40,5 +41,6 @@ t_cub
clist->c_color = -1;
clist->map_w = 0;
clist->line_chk = 0;
+ clist->nsew = 0;
return (clist);
}
diff --git a/src/ft_init_winlx.c b/src/ft_init_winlx.c
index d45f19d..5706685 100644
--- a/src/ft_init_winlx.c
+++ b/src/ft_init_winlx.c
@@ -6,10 +6,10 @@
int
ft_init_winlx(t_cub *clist)
{
- ft_memdel(clist->wlist->wlx);
+ ft_memdel((void**)&clist->wlist->wlx);
if (!(clist->wlist->wlx = mlx_init()))
return (-1);
- ft_memdel(clist->wlist->winptr);
+ ft_memdel((void**)&clist->wlist->winptr);
if (!(clist->wlist->winptr = mlx_new_window(clist->wlist->wlx,
clist->wlist->x_size, clist->wlist->y_size, "Cub3D")))
return (-1);
diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c
index 77f3f47..cc4d920 100644
--- a/src/ft_parse_map.c
+++ b/src/ft_parse_map.c
@@ -60,17 +60,17 @@ ft_parse_it(int fd, t_cub *clist)
return (ft_map_error(clist));
if (ret == 0)
{
- ft_memdel(line);
+ ft_memdel((void**)&line);
return (ft_map_error(clist));
}
if (!line[0])
{
- ft_memdel(line);
+ ft_memdel((void**)&line);
return (ft_parse_it(fd, clist));
}
if (!(words = ft_split(line, ' ')))
{
- ft_memdel(line);
+ ft_memdel((void**)&line);
return (ft_map_error(clist));
}
if ((ret = ft_select_get(words, clist)) == 12)
@@ -79,7 +79,7 @@ ft_parse_it(int fd, t_cub *clist)
return (-1);
return (12);
}
- ft_memdel(line);
+ ft_memdel((void**)&line);
return (ret);
}
diff --git a/src/main.c b/src/main.c
index 8c4ecb9..8c8aad8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -9,13 +9,13 @@ int
if (!(clist = ft_init_cub()))
{
- ft_memdel(clist);
+ ft_memdel((void**)&clist);
return (1);
}
if (!(clist->wlist = ft_init_win()))
{
- ft_memdel(clist->wlist);
- ft_memdel(clist);
+ ft_memdel((void**)&clist->wlist);
+ ft_memdel((void**)&clist);
return (1);
}
ft_parse_map("map/map_one.cub", clist);