add null initialisation of mlx pointers and move mb init closer to begining

This commit is contained in:
hugogogo
2022-05-02 23:36:27 +02:00
parent 75692c09a6
commit a2ed84c5e1
3 changed files with 35 additions and 33 deletions

View File

@@ -1,5 +1,16 @@
#include "cube3d.h"
static void init_null_mlx_ptr(t_game *game)
{
game->img.ptr = NULL;
game->txt.img_n.ptr = NULL;
game->txt.img_s.ptr = NULL;
game->txt.img_e.ptr = NULL;
game->txt.img_w.ptr = NULL;
game->win.ptr = NULL;
game->mlx_ptr = NULL;
}
static void init_map(t_map *map)
{
map->content = NULL;
@@ -11,7 +22,7 @@ static void init_map(t_map *map)
map->plr_y = 0;
}
static void init_txt(t_txt *txt)
static void init_txt_null(t_txt *txt)
{
txt->txt_north = NULL;
txt->txt_south = NULL;
@@ -27,6 +38,8 @@ t_game *init_struct(void)
// map
init_map(&(game->map));
// init textures and floor/ceiling colors
init_txt(&(game->txt));
init_txt_null(&(game->txt));
// put all mlx allocated pointer to null
init_null_mlx_ptr(game);
return (game);
}