Put the custom allocator in its own lib, as to lessen the difficulty to switch between libc's allocator and a custom one (#7)

This commit is contained in:
Maix0 2024-05-14 18:56:53 +02:00 committed by GitHub
parent 713f0f0302
commit cb7f3c3fdf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
85 changed files with 1121 additions and 877 deletions

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/14 18:01:06 by maiboyer #+# #+# */
/* Updated: 2023/12/31 20:14:31 by maiboyer ### ########.fr */
/* Updated: 2024/05/14 18:39:41 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
@ -16,6 +16,7 @@
#include "me/blx/inputs.h"
#include "me/blx/xdata.h"
#include "me/types.h"
#include "me/mem/mem.h"
#include "me/vec/vec_u8.h"
#include "me/printf/printf.h"
#include <mlx.h>
@ -29,7 +30,7 @@ t_blx blx_initialize(t_run_function func, t_free_function free_fn,
{
t_blx ctx;
ctx = (t_blx){.func = func, .app = data, .me_free = free_fn};
ctx = (t_blx){.func = func, .app = data, .mem_free = free_fn};
ctx.mlx = mlx_init();
if (ctx.mlx == NULL)
(me_eprintf("Error:\nfailed to inialize blx (mlx) !\n"), exit(1));
@ -59,14 +60,14 @@ void blx_free(t_blx app)
blx_sprite_free(app._data.screen);
blx_sprite_free(app._data.font);
mlx_do_key_autorepeaton(app.mlx);
if (app.me_free)
app.me_free(app.app);
if (app.mem_free)
app.mem_free(app.app);
if (app.win)
mlx_destroy_window(app.mlx, app.win);
if (app.mlx)
{
mlx_destroy_display(app.mlx);
me_free(app.mlx);
mem_free(app.mlx);
}
vec_u8_free(app.inputs.keysyms_held);
vec_u8_free(app.inputs.keysyms_pressed);