-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfrees.c
More file actions
81 lines (73 loc) · 1.95 KB
/
frees.c
File metadata and controls
81 lines (73 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* frees.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tborges- <tborges-@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/26 16:48:16 by tborges- #+# #+# */
/* Updated: 2024/11/30 17:19:32 by tborges- ### ########.fr */
/* */
/* ************************************************************************** */
#include "so_long.h"
/**
* Frees the memory used by the map.
*/
void free_map(t_map *map)
{
int i;
i = 0;
while (i < map->rows)
{
free(map->data[i]);
i++;
}
free(map->data);
}
/**
* Frees the copy map.
*/
void free_copy(char **copy, int rows)
{
int i;
i = 0;
while (i < rows)
{
free(copy[i]);
i++;
}
free(copy);
}
/**
* Frees the memory used by the game.
*/
void free_textures(t_game *game)
{
t_textures *textures;
textures = &game->textures;
if (textures->wall)
mlx_destroy_image(game->mlx, textures->wall);
if (textures->floor)
mlx_destroy_image(game->mlx, textures->floor);
if (textures->player)
mlx_destroy_image(game->mlx, textures->player);
if (textures->collectible)
mlx_destroy_image(game->mlx, textures->collectible);
if (textures->exit)
mlx_destroy_image(game->mlx, textures->exit);
}
/**
* Frees the memory used by the game.
*/
void free_game(t_game *game)
{
if (game->win)
mlx_destroy_window(game->mlx, game->win);
free_textures(game);
free_map(&game->map);
if (game->mlx)
{
mlx_destroy_display(game->mlx);
free(game->mlx);
}
}