aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--inc/cub3d.h2
-rw-r--r--src/ft_draw_sprite.c3
-rw-r--r--src/ft_sort_s_t.c14
3 files changed, 11 insertions, 8 deletions
diff --git a/inc/cub3d.h b/inc/cub3d.h
index 92e57ce..b7f8a36 100644
--- a/inc/cub3d.h
+++ b/inc/cub3d.h
@@ -87,7 +87,7 @@ void ft_draw_circle(float a, float b,
int32_t color, t_cub *cl);
void ft_draw_verline(t_cub *cl, int32_t x, int32_t y, int32_t y2);
void ft_sprite_h_w(t_cub *cl, t_sprite *sprite);
-void ft_alloc_dist_tab(float ***dist_tab, t_cub *cl);
+float **ft_alloc_dist_tab(void);
void ft_sort_sprites(t_cub *cl, int16_t i, int16_t j);
void ft_sort_s_t(t_cub *cl, float **dist_tab);
void ft_calc_sprite(t_cub *cl);
diff --git a/src/ft_draw_sprite.c b/src/ft_draw_sprite.c
index 0c5a8b2..423080d 100644
--- a/src/ft_draw_sprite.c
+++ b/src/ft_draw_sprite.c
@@ -41,7 +41,8 @@ void
{
float **dist_tab;
- ft_alloc_dist_tab(&dist_tab, cl);
+ if (!(dist_tab = ft_alloc_dist_tab()))
+ ft_error(FT_RET_ALLOC_ERR, FT_ERR_ALLOCATE, cl);
while (++jt < cl->mlist.sprite_var)
{
while (++it < cl->mlist.sprite_nbr[jt])
diff --git a/src/ft_sort_s_t.c b/src/ft_sort_s_t.c
index 6a74c61..6c08882 100644
--- a/src/ft_sort_s_t.c
+++ b/src/ft_sort_s_t.c
@@ -15,20 +15,22 @@
#include <stdlib.h>
#include <stdint.h>
-void
- ft_alloc_dist_tab(float ***dist_tab, t_cub *cl)
+float
+ **ft_alloc_dist_tab(void)
{
uint16_t i;
+ float **dist_tab;
- if (!(*dist_tab = (float **)malloc(8 * sizeof(float*))))
- ft_error(FT_RET_ALLOC_ERR, FT_ERR_ALLOCATE, cl);
+ if (!(dist_tab = (float **)malloc(8 * sizeof(float*))))
+ return (NULL);
i = 0;
while (i < 8)
{
- if (!((*dist_tab)[i] = (float *)malloc(4096 * sizeof(float))))
- ft_error(FT_RET_ALLOC_ERR, FT_ERR_ALLOCATE, cl);
+ if (!(dist_tab[i] = (float *)malloc(4096 * sizeof(float))))
+ return (NULL);
i++;
}
+ return (dist_tab);
}
static void