Skip to content

Commit

Permalink
fixed leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Yesim Zaim committed Feb 7, 2024
1 parent a2ae9df commit ae3c212
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ RUN_CMD := ./$(NAME) test_maps/valid_tex.cub

# CFLAGS += -Wall -Wextra -Werror
# CFLAGS += -Wall -Wextra
CFLAGS += -g -fsanitize=address
# CFLAGS += -g
# CFLAGS += -g -fsanitize=address
# # CFLAGS += -g
# CFLAGS += -Ofast -flto -march=native

LIBFT := libft/build/libft.a
Expand Down
2 changes: 1 addition & 1 deletion src/cub3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: yzaim <[email protected]> +#+ */
/* +#+ */
/* Created: 2024/01/08 15:24:47 by yzaim #+# #+# */
/* Updated: 2024/02/02 15:42:44 by yesimzaim ######## odam.nl */
/* Updated: 2024/02/07 12:04:12 by yzaim ######## odam.nl */
/* */
/* ************************************************************************** */

Expand Down
2 changes: 1 addition & 1 deletion src/game/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: yzaim <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/08 15:26:51 by yzaim #+# #+# */
/* Updated: 2024/01/29 12:51:57 by yesimzaim ######## odam.nl */
/* Updated: 2024/02/07 12:15:51 by yzaim ######## odam.nl */
/* */
/* ************************************************************************** */

Expand Down
8 changes: 5 additions & 3 deletions src/game/sprite.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: jboeve <[email protected]> +#+ */
/* +#+ */
/* Created: 2024/01/25 16:01:20 by jboeve #+# #+# */
/* Updated: 2024/01/29 13:00:59 by yesimzaim ######## odam.nl */
/* Updated: 2024/02/07 12:48:55 by yzaim ######## odam.nl */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -58,7 +58,9 @@ void sprite_calculate(t_player *p)
}

sprite_sort(p->sprite_dist, p->sprite_order, p->meta->attributes.sprite_count);


// print_double_array("SPRITE DIST", p->sprite_dist, p->meta->attributes.sprite_count);

i = 0;
while (i < p->meta->attributes.sprite_count)
{
Expand All @@ -70,7 +72,7 @@ void sprite_calculate(t_player *p)


const t_vec2d transform = {inv_det * (p->direction.y * s_pos.x - p->direction.x * s_pos.y),
inv_det * (-p->cam_plane.y * s_pos.x + p->cam_plane.x * s_pos.y)};
inv_det * (-(p->cam_plane.y) * s_pos.x + p->cam_plane.x * s_pos.y)};

const int32_t sprite_screen_x = (int32_t)(p->meta->image->width / 2) * (1 + transform.x / transform.y);

Expand Down
5 changes: 3 additions & 2 deletions src/parser/lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: yzaim <[email protected]> +#+ */
/* +#+ */
/* Created: 2024/01/08 15:30:18 by yzaim #+# #+# */
/* Updated: 2024/02/01 16:26:58 by yesimzaim ######## odam.nl */
/* Updated: 2024/02/07 11:16:09 by yzaim ######## odam.nl */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -178,6 +178,7 @@ int lexer(t_meta *meta, char *map_file)
if (!file)
return(EXIT_FAILURE);
if (lex(file, &meta->map, &meta->elements))
return (free_t_flag_list(&meta->elements), EXIT_FAILURE); //also free everything in case of error!
return (free(file), free_t_flag_list(&meta->elements), EXIT_FAILURE); //also free everything in case of error!
free(file);
return (EXIT_SUCCESS);
}
2 changes: 1 addition & 1 deletion src/set_textures.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: yzaim <[email protected]> +#+ */
/* +#+ */
/* Created: 2024/01/08 15:56:45 by yzaim #+# #+# */
/* Updated: 2024/01/25 00:29:36 by joppe ######## odam.nl */
/* Updated: 2024/02/07 12:03:56 by yzaim ######## odam.nl */
/* */
/* ************************************************************************** */

Expand Down
12 changes: 8 additions & 4 deletions src/utils/free.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* free.c :+: :+: */
/* free.c :+: :+: */
/* +:+ */
/* By: yzaim <[email protected]> +#+ */
/* +#+ */
/* Created: 2024/01/08 15:53:55 by yzaim #+# #+# */
/* Updated: 2024/01/24 11:22:41 by yzaim ######## odam.nl */
/* Updated: 2024/02/07 12:04:35 by yzaim ######## odam.nl */
/* */
/* ************************************************************************** */

Expand All @@ -19,7 +19,9 @@ void f_tex(t_tex *attr)
if (attr->tex_path)
free(attr->tex_path);
if (attr->tex)
{
mlx_delete_texture(attr->tex);
}
}

static void free_t_tex(t_attr *attributes)
Expand All @@ -30,6 +32,7 @@ static void free_t_tex(t_attr *attributes)
f_tex(&attributes->w);
f_tex(&attributes->f);
f_tex(&attributes->c);
f_tex(&attributes->c_alt);
}

void free_t_flag_list(t_flag **list)
Expand Down Expand Up @@ -67,6 +70,7 @@ void meta_free(t_meta *meta)
{
free_t_tex(&meta->attributes);
free(meta->map.level);
if (meta->attributes.sprites)
free_t_sprites(&meta->attributes.sprites, meta->attributes.sprite_count);
free_t_sprites(&meta->attributes.sprites, meta->attributes.sprite_count);
free(meta->player.sprite_dist);
free(meta->player.sprite_order);
}

0 comments on commit ae3c212

Please sign in to comment.