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:
parent
713f0f0302
commit
cb7f3c3fdf
85 changed files with 1121 additions and 877 deletions
34
stdme/src/mem/allocator.c
Normal file
34
stdme/src/mem/allocator.c
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* allocator.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/14 18:26:27 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/05/14 18:28:24 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "aq/allocator.h"
|
||||
#include "aq/libc_wrapper.h"
|
||||
|
||||
t_allocator *global_allocator(void)
|
||||
{
|
||||
static t_allocator global_alloc = {};
|
||||
static bool init = false;
|
||||
if (!init)
|
||||
{
|
||||
init = true;
|
||||
global_alloc = lc_init();
|
||||
}
|
||||
return (&global_alloc);
|
||||
}
|
||||
|
||||
void uninit_global_allocator(void)
|
||||
{
|
||||
t_allocator *allocator;
|
||||
|
||||
allocator = global_allocator();
|
||||
allocator->uninit(allocator);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue