From b96c5e1e6691f1236b9e0a19924d7aab612f9724 Mon Sep 17 00:00:00 2001 From: Maix0 Date: Wed, 22 May 2024 15:01:40 +0200 Subject: [PATCH] Switched back to libc's allocator until I fix every bug --- parser/src/api.h | 2 +- stdme/src/mem/allocator.c | 6 +++--- stdme/src/mem/mem_alloc.c | 10 +++++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/parser/src/api.h b/parser/src/api.h index 2f1cf1ea..31e195e1 100644 --- a/parser/src/api.h +++ b/parser/src/api.h @@ -39,7 +39,7 @@ #define STACK_VERSION_NONE ((t_stack_version)-1) #define TS_DECODE_ERROR (-1) -#if false +#if true # undef malloc # undef calloc # undef realloc diff --git a/stdme/src/mem/allocator.c b/stdme/src/mem/allocator.c index 0a179b57..4fb35b20 100644 --- a/stdme/src/mem/allocator.c +++ b/stdme/src/mem/allocator.c @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/14 18:26:27 by maiboyer #+# #+# */ -/* Updated: 2024/05/18 18:48:25 by maiboyer ### ########.fr */ +/* Updated: 2024/05/22 14:58:57 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -25,8 +25,8 @@ t_allocator *global_allocator(void) if (!init) { init = true; - global_alloc = m_init(); - // global_alloc = lc_init(); + //global_alloc = m_init(); + global_alloc = lc_init(); } return (&global_alloc); } diff --git a/stdme/src/mem/mem_alloc.c b/stdme/src/mem/mem_alloc.c index 8766cd79..772f3ef4 100644 --- a/stdme/src/mem/mem_alloc.c +++ b/stdme/src/mem/mem_alloc.c @@ -6,19 +6,23 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/12/06 14:47:49 by maiboyer #+# #+# */ -/* Updated: 2024/05/14 18:32:31 by maiboyer ### ########.fr */ +/* Updated: 2024/05/22 15:01:06 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ -#include "me/mem/mem.h" #include "me/mem/_allocator.h" +#include "me/mem/mem.h" void *mem_alloc(t_usize size) { t_allocator *a; + void *ret; a = global_allocator(); - return (a->alloc(a, size)); + ret = a->alloc(a, size); + if (ret != NULL) + mem_set_zero(ret, size); + return (ret); } void mem_free(void *ptr)