From 7f3461875572335eedffa272226199dd1c2fc92a Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Mon, 16 Mar 2020 19:28:18 +0100 Subject: Cleaner memdels --- src/ft_draw_scene.c | 2 +- src/ft_exit.c | 36 ++++++++++++++++++------------------ src/ft_free_words.c | 8 ++++---- src/ft_get_map.c | 18 +++++++++--------- src/ft_get_music.c | 4 ++-- src/ft_get_path_nl.c | 2 +- src/ft_get_skybox.c | 2 +- src/ft_get_sprite.c | 2 +- src/ft_get_tex.c | 8 ++++---- src/ft_get_tex_extra.c | 4 ++-- src/ft_get_tex_nl.c | 2 +- src/ft_get_traps.c | 2 +- src/ft_init_sfx.c | 4 ++-- src/ft_init_winlx.c | 2 +- src/ft_parse_map.c | 8 ++++---- src/ft_raycasting.c | 4 ++-- src/ft_save_to_bmp.c | 10 +++++----- src/ft_warp_level.c | 36 ++++++++++++++++++------------------ 18 files changed, 77 insertions(+), 77 deletions(-) (limited to 'src') diff --git a/src/ft_draw_scene.c b/src/ft_draw_scene.c index 1edef2a..0f34567 100644 --- a/src/ft_draw_scene.c +++ b/src/ft_draw_scene.c @@ -34,7 +34,7 @@ static int8_t (uint32_t)x, y, 0x002288da, str); - ft_memdel((void**)&str); + ft_memdel((void*)&str); return (0); } diff --git a/src/ft_exit.c b/src/ft_exit.c index 6b1fb5e..2e997fb 100644 --- a/src/ft_exit.c +++ b/src/ft_exit.c @@ -28,30 +28,30 @@ static void i = 0; while (i < 8) { - ft_memdel((void**)&clist->sprites[i]); + ft_memdel((void*)&clist->sprites[i]); i++; } - ft_memdel((void**)&clist->sprites); - ft_memdel((void**)&clist); + ft_memdel((void*)&clist->sprites); + ft_memdel((void*)&clist); } static void ft_free_lists(t_cub *clist) { - ft_memdel((void**)&clist->mlist.filename); - ft_memdel((void**)&clist->mlist.no_tex_path); - ft_memdel((void**)&clist->mlist.so_tex_path); - ft_memdel((void**)&clist->mlist.ea_tex_path); - ft_memdel((void**)&clist->mlist.we_tex_path); - ft_memdel((void**)&clist->mlist.nl_tex_path); - ft_memdel((void**)&clist->mlist.fl_tex_path); - ft_memdel((void**)&clist->mlist.ce_tex_path); - ft_memdel((void**)&clist->mlist.nlevel_path); - ft_memdel((void**)&clist->mlist.skybox_path); - ft_memdel((void**)&clist->mlist.traps_path); - ft_memdel((void**)&clist->mlist.music_path); - ft_memdel((void**)&clist->mlist.music_cmd); - ft_memdel((void**)&clist->mlist.mapl); + ft_memdel((void*)&clist->mlist.filename); + ft_memdel((void*)&clist->mlist.no_tex_path); + ft_memdel((void*)&clist->mlist.so_tex_path); + ft_memdel((void*)&clist->mlist.ea_tex_path); + ft_memdel((void*)&clist->mlist.we_tex_path); + ft_memdel((void*)&clist->mlist.nl_tex_path); + ft_memdel((void*)&clist->mlist.fl_tex_path); + ft_memdel((void*)&clist->mlist.ce_tex_path); + ft_memdel((void*)&clist->mlist.nlevel_path); + ft_memdel((void*)&clist->mlist.skybox_path); + ft_memdel((void*)&clist->mlist.traps_path); + ft_memdel((void*)&clist->mlist.music_path); + ft_memdel((void*)&clist->mlist.music_cmd); + ft_memdel((void*)&clist->mlist.mapl); ft_free_words(clist->mlist.map); ft_free_words(clist->mlist.mcmd_words); ft_free_words(clist->sfx.death); @@ -61,7 +61,7 @@ static void ft_free_words(clist->sfx.trap); ft_free_sprites(clist->mlist.sprite_path); if (!clist->wlist.inited) - ft_memdel((void**)&clist->wlist.winptr); + ft_memdel((void*)&clist->wlist.winptr); } static void diff --git a/src/ft_free_words.c b/src/ft_free_words.c index a90b959..3ca01c8 100644 --- a/src/ft_free_words.c +++ b/src/ft_free_words.c @@ -20,10 +20,10 @@ uint8_t i = 0; while (i < 9) { - ft_memdel((void**)&sprites[i]); + ft_memdel((void*)&sprites[i]); i++; } - ft_memdel((void**)&sprites); + ft_memdel((void*)&sprites); return (0); } @@ -35,9 +35,9 @@ uint8_t i = 0; while (words[i]) { - ft_memdel((void**)&words[i]); + ft_memdel((void*)&words[i]); i++; } - ft_memdel((void**)&words); + ft_memdel((void*)&words); return (0); } diff --git a/src/ft_get_map.c b/src/ft_get_map.c index 08c9734..8602ce3 100644 --- a/src/ft_get_map.c +++ b/src/ft_get_map.c @@ -58,22 +58,22 @@ int clist->mlist.map_start = clist->mlist.line_chk; if (!line[0]) { - ft_memdel((void**)&line); + ft_memdel((void*)&line); ft_sprintf(clist->errmsg, FT_ERR_READ); return (-1); } if (ft_check_map_line(line, 1, clist) < 0) { - ft_memdel((void**)&line); + ft_memdel((void*)&line); return (-1); } - ft_memdel((void**)&clist->mlist.mapl); + ft_memdel((void*)&clist->mlist.mapl); if (ft_cat_mapl(line, clist) < 0) { - ft_memdel((void**)&line); + ft_memdel((void*)&line); return (-1); } - ft_memdel((void**)&line); + ft_memdel((void*)&line); return (1); } @@ -92,17 +92,17 @@ int { if (!line[0]) ft_sprintf(clist->errmsg, FT_ERR_MAP_EMPL); - ft_memdel((void**)&line); + ft_memdel((void*)&line); return (-1); } - ft_memdel((void**)&line); + ft_memdel((void*)&line); } - ft_memdel((void**)&line); + ft_memdel((void*)&line); clist->mlist.mapl[clist->mlist.mapl_len - 1] = '\0'; ft_free_words(clist->mlist.map); clist->mlist.map = ft_split(clist->mlist.mapl, '\n'); clist->mlist.map_h = ft_get_map_h(clist->mlist.map); clist->mlist.map_w = ft_get_map_w(clist->mlist.map); - ft_memdel((void**)&clist->mlist.mapl); + ft_memdel((void*)&clist->mlist.mapl); return (0); } diff --git a/src/ft_get_music.c b/src/ft_get_music.c index 7a8d36f..6d4f299 100644 --- a/src/ft_get_music.c +++ b/src/ft_get_music.c @@ -22,7 +22,7 @@ static int8_t len = ft_strlen(mlist->music_path); len += ft_strlen(FT_SND_CMD) - 2; - ft_memdel((void**)&mlist->music_cmd); + ft_memdel((void*)&mlist->music_cmd); if (!(mlist->music_cmd = (char *)malloc((len + 1) * sizeof(char)))) return (-1); ft_sprintf(mlist->music_cmd, FT_SND_CMD, @@ -46,7 +46,7 @@ int8_t ft_sprintf(clist->errmsg, FT_ERR_NOT_A_WAV); return (-1); } - ft_memdel((void**)&clist->mlist.music_path); + ft_memdel((void*)&clist->mlist.music_path); if (!(clist->mlist.music_path = ft_strdup(*(words + 1)))) { ft_sprintf(clist->errmsg, FT_ERR_ALLOCATE); diff --git a/src/ft_get_path_nl.c b/src/ft_get_path_nl.c index 68de5c6..38f5b36 100644 --- a/src/ft_get_path_nl.c +++ b/src/ft_get_path_nl.c @@ -27,7 +27,7 @@ int8_t ft_sprintf(clist->errmsg, FT_ERR_NOT_A_CUB); return (-1); } - ft_memdel((void**)&clist->mlist.nlevel_path); + ft_memdel((void*)&clist->mlist.nlevel_path); if (!(clist->mlist.nlevel_path = ft_strdup(*(words + 1)))) { ft_sprintf(clist->errmsg, FT_ERR_ALLOCATE); diff --git a/src/ft_get_skybox.c b/src/ft_get_skybox.c index d2f1f02..1e55b85 100644 --- a/src/ft_get_skybox.c +++ b/src/ft_get_skybox.c @@ -27,7 +27,7 @@ int8_t ft_sprintf(clist->errmsg, FT_ERR_NOT_A_XPM); return (-1); } - ft_memdel((void**)&clist->mlist.skybox_path); + ft_memdel((void*)&clist->mlist.skybox_path); if (!(clist->mlist.skybox_path = ft_strdup(*(words + 1)))) { ft_sprintf(clist->errmsg, FT_ERR_ALLOCATE); diff --git a/src/ft_get_sprite.c b/src/ft_get_sprite.c index ed44d9b..5a5ecd0 100644 --- a/src/ft_get_sprite.c +++ b/src/ft_get_sprite.c @@ -53,7 +53,7 @@ static int8_t static int8_t ft_get_sprite_norme(int8_t id, char **words, t_cub *clist) { - ft_memdel((void**)&clist->mlist.sprite_path[id]); + ft_memdel((void*)&clist->mlist.sprite_path[id]); if (!(clist->mlist.sprite_path[id] = ft_strdup(*(words + 1)))) { ft_sprintf(clist->errmsg, FT_ERR_ALLOCATE); diff --git a/src/ft_get_tex.c b/src/ft_get_tex.c index f8a817c..21096eb 100644 --- a/src/ft_get_tex.c +++ b/src/ft_get_tex.c @@ -27,7 +27,7 @@ int8_t ft_sprintf(clist->errmsg, "%s", FT_ERR_NOT_A_XPM); return (-1); } - ft_memdel((void**)&clist->mlist.no_tex_path); + ft_memdel((void*)&clist->mlist.no_tex_path); if (!(clist->mlist.no_tex_path = ft_strdup(*(words + 1)))) { ft_sprintf(clist->errmsg, "%s", FT_ERR_ALLOCATE); @@ -54,7 +54,7 @@ int8_t ft_sprintf(clist->errmsg, "%s", FT_ERR_NOT_A_XPM); return (-1); } - ft_memdel((void**)&clist->mlist.so_tex_path); + ft_memdel((void*)&clist->mlist.so_tex_path); if (!(clist->mlist.so_tex_path = ft_strdup(*(words + 1)))) { ft_sprintf(clist->errmsg, "%s", FT_ERR_ALLOCATE); @@ -81,7 +81,7 @@ int8_t ft_sprintf(clist->errmsg, "%s", FT_ERR_NOT_A_XPM); return (-1); } - ft_memdel((void**)&clist->mlist.ea_tex_path); + ft_memdel((void*)&clist->mlist.ea_tex_path); if (!(clist->mlist.ea_tex_path = ft_strdup(*(words + 1)))) { ft_sprintf(clist->errmsg, "%s", FT_ERR_ALLOCATE); @@ -108,7 +108,7 @@ int8_t ft_sprintf(clist->errmsg, "%s", FT_ERR_NOT_A_XPM); return (-1); } - ft_memdel((void**)&clist->mlist.we_tex_path); + ft_memdel((void*)&clist->mlist.we_tex_path); if (!(clist->mlist.we_tex_path = ft_strdup(*(words + 1)))) { ft_sprintf(clist->errmsg, "%s", FT_ERR_ALLOCATE); diff --git a/src/ft_get_tex_extra.c b/src/ft_get_tex_extra.c index 25f9c23..77f053b 100644 --- a/src/ft_get_tex_extra.c +++ b/src/ft_get_tex_extra.c @@ -26,7 +26,7 @@ int8_t ft_sprintf(clist->errmsg, "%s", FT_ERR_NOT_A_XPM); return (-1); } - ft_memdel((void**)&clist->mlist.fl_tex_path); + ft_memdel((void*)&clist->mlist.fl_tex_path); if (!(clist->mlist.fl_tex_path = ft_strdup(*(words + 1)))) { ft_sprintf(clist->errmsg, "%s", FT_ERR_ALLOCATE); @@ -54,7 +54,7 @@ int8_t ft_sprintf(clist->errmsg, "%s", FT_ERR_NOT_A_XPM); return (-1); } - ft_memdel((void**)&clist->mlist.ce_tex_path); + ft_memdel((void*)&clist->mlist.ce_tex_path); if (!(clist->mlist.ce_tex_path = ft_strdup(*(words + 1)))) { ft_sprintf(clist->errmsg, "%s", FT_ERR_ALLOCATE); diff --git a/src/ft_get_tex_nl.c b/src/ft_get_tex_nl.c index bb071f7..0931df1 100644 --- a/src/ft_get_tex_nl.c +++ b/src/ft_get_tex_nl.c @@ -27,7 +27,7 @@ int8_t ft_sprintf(clist->errmsg, "%s", FT_ERR_NOT_A_XPM); return (-1); } - ft_memdel((void**)&clist->mlist.nl_tex_path); + ft_memdel((void*)&clist->mlist.nl_tex_path); if (!(clist->mlist.nl_tex_path = ft_strdup(*(words + 1)))) { ft_sprintf(clist->errmsg, "%s", FT_ERR_ALLOCATE); diff --git a/src/ft_get_traps.c b/src/ft_get_traps.c index 0235bb5..b7d12e1 100644 --- a/src/ft_get_traps.c +++ b/src/ft_get_traps.c @@ -55,7 +55,7 @@ int8_t ft_sprintf(clist->errmsg, "%s", FT_ERR_NOT_A_XPM); return (-1); } - ft_memdel((void**)&clist->mlist.traps_path); + ft_memdel((void*)&clist->mlist.traps_path); if (!(clist->mlist.traps_path = ft_strdup(*(words + 1)))) { ft_sprintf(clist->errmsg, "%s", FT_ERR_ALLOCATE); diff --git a/src/ft_init_sfx.c b/src/ft_init_sfx.c index 9049250..1a06d11 100644 --- a/src/ft_init_sfx.c +++ b/src/ft_init_sfx.c @@ -31,10 +31,10 @@ static int8_t ft_sprintf(tmp, FT_SND_CMD, path); if (!(*target = ft_split(tmp, ' '))) { - ft_memdel((void**)&tmp); + ft_memdel((void*)&tmp); return (-1); } - ft_memdel((void**)&tmp); + ft_memdel((void*)&tmp); return (0); } diff --git a/src/ft_init_winlx.c b/src/ft_init_winlx.c index dee4009..59d0b58 100644 --- a/src/ft_init_winlx.c +++ b/src/ft_init_winlx.c @@ -26,7 +26,7 @@ int int ft_init_winptr(t_cub *clist) { - ft_memdel((void**)&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 f1df73d..79c00d2 100644 --- a/src/ft_parse_map.c +++ b/src/ft_parse_map.c @@ -42,7 +42,7 @@ static void static int8_t ft_error_here(const char *errmsg, char *line, t_cub *clist) { - ft_memdel((void**)&line); + ft_memdel((void*)&line); return (ft_map_error(errmsg, clist)); } @@ -60,7 +60,7 @@ static int8_t return (ft_error_here(FT_ERR_UNFINISHED, line, clist)); if (!line[0]) { - ft_memdel((void**)&line); + ft_memdel((void*)&line); return (ft_parse_it(fd, clist)); } if (ft_ischarset("1 ", line[0])) @@ -70,14 +70,14 @@ static int8_t return (ft_error_here(FT_ERR_ILL_ENTRY, line, clist)); if ((ret = ft_select_get(words, clist)) == FT_PARSE_END_RET) return ((ft_get_map_first_line(line, clist) < 0) ? (-1) : (25)); - ft_memdel((void**)&line); + ft_memdel((void*)&line); return (ret); } void ft_save_name(const char *map_path, t_cub *clist) { - ft_memdel((void**)&clist->mlist.filename); + ft_memdel((void*)&clist->mlist.filename); if (!(clist->mlist.filename = (char*)malloc((ft_strlen(map_path) + 1) * sizeof(char)))) ft_error(FT_RET_ALLOC_ERR, FT_ERR_ALLOCATE, clist); diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c index 743dc36..aa050c5 100644 --- a/src/ft_raycasting.c +++ b/src/ft_raycasting.c @@ -107,6 +107,6 @@ void ft_floor_cast(cl); ft_calc_sprite(cl); ft_calc_trap(cl); - ft_memdel((void**)&cl->rlist.wall_dist_tab); - ft_memdel((void**)&cl->rlist.wall_bz); + ft_memdel((void*)&cl->rlist.wall_dist_tab); + ft_memdel((void*)&cl->rlist.wall_bz); } diff --git a/src/ft_save_to_bmp.c b/src/ft_save_to_bmp.c index ae3a2b6..1737226 100644 --- a/src/ft_save_to_bmp.c +++ b/src/ft_save_to_bmp.c @@ -111,16 +111,16 @@ int8_t return (-1); if (!(bmp = ft_convert_image_to_bmp(cl->img, cl))) { - ft_memdel((void**)&fname); + ft_memdel((void*)&fname); return (-1); } if (ft_write_bmp(fname, cl->wlist.y_size, cl->wlist.x_size, bmp) < 0) { - ft_memdel((void**)&bmp); - ft_memdel((void**)&fname); + ft_memdel((void*)&bmp); + ft_memdel((void*)&fname); return (-1); } - ft_memdel((void**)&bmp); - ft_memdel((void**)&fname); + ft_memdel((void*)&bmp); + ft_memdel((void*)&fname); return (0); } diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c index 130b33a..bc903f0 100644 --- a/src/ft_warp_level.c +++ b/src/ft_warp_level.c @@ -23,20 +23,20 @@ static void ft_del_map(t_map *ml) { - ft_memdel((void**)&ml->filename); - ft_memdel((void**)&ml->no_tex_path); - ft_memdel((void**)&ml->so_tex_path); - ft_memdel((void**)&ml->ea_tex_path); - ft_memdel((void**)&ml->we_tex_path); - ft_memdel((void**)&ml->nl_tex_path); - ft_memdel((void**)&ml->fl_tex_path); - ft_memdel((void**)&ml->ce_tex_path); - ft_memdel((void**)&ml->nlevel_path); - ft_memdel((void**)&ml->skybox_path); - ft_memdel((void**)&ml->traps_path); - ft_memdel((void**)&ml->music_path); - ft_memdel((void**)&ml->music_cmd); - ft_memdel((void**)&ml->mapl); + ft_memdel((void*)&ml->filename); + ft_memdel((void*)&ml->no_tex_path); + ft_memdel((void*)&ml->so_tex_path); + ft_memdel((void*)&ml->ea_tex_path); + ft_memdel((void*)&ml->we_tex_path); + ft_memdel((void*)&ml->nl_tex_path); + ft_memdel((void*)&ml->fl_tex_path); + ft_memdel((void*)&ml->ce_tex_path); + ft_memdel((void*)&ml->nlevel_path); + ft_memdel((void*)&ml->skybox_path); + ft_memdel((void*)&ml->traps_path); + ft_memdel((void*)&ml->music_path); + ft_memdel((void*)&ml->music_cmd); + ft_memdel((void*)&ml->mapl); ft_free_sprites(ml->sprite_path); ft_free_words(ml->map); ft_free_words(ml->mcmd_words); @@ -65,8 +65,8 @@ static void ft_del_extra_sprites(cl); i = -1; while (++i < 8) - ft_memdel((void**)&cl->sprites[i]); - ft_memdel((void**)&cl->sprites); + ft_memdel((void*)&cl->sprites[i]); + ft_memdel((void*)&cl->sprites); } static void @@ -111,8 +111,8 @@ int8_t ft_parse_map(next_path, cl); ft_treat_music(isoldmus, tmp_mup, cl); if (isoldmus) - ft_memdel((void**)&tmp_mup); + ft_memdel((void*)&tmp_mup); ft_wall_tex_init(cl); - ft_memdel((void**)&next_path); + ft_memdel((void*)&next_path); return (0); } -- cgit v1.2.3