From cfbb84c0289d4505f23965ec3536b8799f6e4689 Mon Sep 17 00:00:00 2001 From: maix0 Date: Wed, 23 Oct 2024 15:36:18 +0200 Subject: [PATCH] update: changed some stuff --- allocator/Filelist.aq.mk | 1 - allocator/src/lc_alloc/functions1.c | 20 ++++++++++---------- allocator/src/me_alloc/functions1.c | 8 ++++---- allocator/src/me_alloc/functions2.c | 19 ------------------- allocator/src/me_alloc/pages.c | 12 ++++++------ exec/src/_read_dir.c | 3 ++- exec/src/builtins/export.c | 5 ++--- exec/src/run_ast/run_list.c | 6 +++--- exec/src/run_ast/run_subshell.c | 2 +- parser/src/yard/yard.c | 6 +++--- 10 files changed, 31 insertions(+), 51 deletions(-) delete mode 100644 allocator/src/me_alloc/functions2.c diff --git a/allocator/Filelist.aq.mk b/allocator/Filelist.aq.mk index ead60e1c..1237472a 100644 --- a/allocator/Filelist.aq.mk +++ b/allocator/Filelist.aq.mk @@ -3,7 +3,6 @@ lc_alloc/functions1 \ lc_alloc/functions2 \ me_alloc/find_block \ me_alloc/functions1 \ -me_alloc/functions2 \ me_alloc/internals \ me_alloc/merge_blocks \ me_alloc/pages \ diff --git a/allocator/src/lc_alloc/functions1.c b/allocator/src/lc_alloc/functions1.c index 9280f9d2..949582af 100644 --- a/allocator/src/lc_alloc/functions1.c +++ b/allocator/src/lc_alloc/functions1.c @@ -14,39 +14,39 @@ #include "aq/libc_wrapper.h" #include "me/types.h" -void *__libc_malloc(t_usize size); -void *__libc_calloc(t_usize size, t_usize elem); -void *__libc_realloc(void *ptr, t_usize size); -void *__libc_reallocarray(void *ptr, t_usize size, t_usize elem); -void __libc_free(void *ptr); +void *malloc(t_usize size); +void *calloc(t_usize size, t_usize elem); +void *realloc(void *ptr, t_usize size); +void *reallocarray(void *ptr, t_usize size, t_usize elem); +void free(void *ptr); void *lc_malloc(t_allocator *self, t_usize size) { (void)(self); - return (__libc_malloc(size)); + return (malloc(size)); } void *lc_calloc(t_allocator *self, t_usize size, t_usize elem) { (void)(self); - return (__libc_calloc(size, elem)); + return (calloc(size, elem)); } void *lc_realloc(t_allocator *self, void *ptr, t_usize size) { (void)(self); - return (__libc_realloc(ptr, size)); + return (realloc(ptr, size)); } void *lc_realloc_array(t_allocator *self, void *ptr, t_usize size, t_usize elem) { (void)(self); - return (__libc_reallocarray(ptr, size, elem)); + return (reallocarray(ptr, size, elem)); } void lc_free(t_allocator *self, void *ptr) { (void)(self); - return (__libc_free(ptr)); + return (free(ptr)); } diff --git a/allocator/src/me_alloc/functions1.c b/allocator/src/me_alloc/functions1.c index 7af4847b..427bd30a 100644 --- a/allocator/src/me_alloc/functions1.c +++ b/allocator/src/me_alloc/functions1.c @@ -18,8 +18,8 @@ #include #include -void *__libc_malloc(t_usize size); -void __libc_free(void *ptr); +void *malloc(t_usize size); +void free(void *ptr); void *m_malloc(struct s_allocator_melloc *self, t_usize size) { @@ -64,14 +64,14 @@ void m_uninit(struct s_allocator_melloc *self) if (list->pages[idx].data != NULL) { vg_mempool_free(list, list->pages[idx].data); - __libc_free(list->pages[idx].data); + free(list->pages[idx].data); list->pages[idx].size = 0; list->pages[idx].data = NULL; } idx++; } list_next = list->next; - (__libc_free(list), vg_mempool_destroy(list), \ + (free(list), vg_mempool_destroy(list), \ vg_mem_no_access(list, sizeof(*list))); list = list_next; } diff --git a/allocator/src/me_alloc/functions2.c b/allocator/src/me_alloc/functions2.c deleted file mode 100644 index a91a035b..00000000 --- a/allocator/src/me_alloc/functions2.c +++ /dev/null @@ -1,19 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* functions2.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: maiboyer +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/14 18:06:34 by maiboyer #+# #+# */ -/* Updated: 2024/10/12 17:51:05 by rparodi ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "aq/allocator.h" -#include "aq/libc_wrapper.h" - -// void lc_uninit(t_allocator *self) -// { -// (void)(self); -// } diff --git a/allocator/src/me_alloc/pages.c b/allocator/src/me_alloc/pages.c index e2cc978b..9e17e7a9 100644 --- a/allocator/src/me_alloc/pages.c +++ b/allocator/src/me_alloc/pages.c @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/07/10 16:51:10 by maiboyer #+# #+# */ -/* Updated: 2024/10/12 17:51:07 by rparodi ### ########.fr */ +/* Updated: 2024/10/23 14:52:47 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,8 +17,8 @@ #include "me/types.h" #include -void *__libc_malloc(t_usize size); -void __libc_free(void *ptr); +void *malloc(t_usize size); +void free(void *ptr); t_error alloc_page_list(t_page_list **out) { @@ -26,7 +26,7 @@ t_error alloc_page_list(t_page_list **out) if (out == NULL) return (ERROR); - val = __libc_malloc(sizeof(*val)); + val = malloc(sizeof(*val)); if (val == NULL) return (ERROR); mem_set_zero(val, sizeof(*val)); @@ -43,10 +43,10 @@ t_error _alloc_new_page_inner(t_usize page_size, t_page_list *list) if (list == NULL) return (ERROR); vg_mem_defined(list, sizeof(*list)); - list->pages[list->len].data = __libc_malloc(page_size); - mem_set_zero(list->pages[list->len].data, page_size); + list->pages[list->len].data = malloc(page_size); if (list->pages[list->len].data == NULL) return (ERROR); + mem_set_zero(list->pages[list->len].data, page_size); list->pages[list->len].size = page_size; vg_mempool_alloc(list, list->pages[list->len].data, page_size); chunk = get_first_block(&list->pages[list->len]); diff --git a/exec/src/_read_dir.c b/exec/src/_read_dir.c index 6efa76e6..d545844e 100644 --- a/exec/src/_read_dir.c +++ b/exec/src/_read_dir.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/09/17 21:43:33 by rparodi #+# #+# */ -/* Updated: 2024/10/12 17:51:19 by rparodi ### ########.fr */ +/* Updated: 2024/10/23 15:33:10 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -58,6 +58,7 @@ t_error listing_files(t_string path, t_vec_str *out) continue ; vec_str_push(&ret, str_clone(entry->d_name)); } + close_dir(tmp); return (*out = ret, NO_ERROR); } diff --git a/exec/src/builtins/export.c b/exec/src/builtins/export.c index 3bd5c218..b4146551 100644 --- a/exec/src/builtins/export.c +++ b/exec/src/builtins/export.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/07 14:13:41 by rparodi #+# #+# */ -/* Updated: 2024/10/13 17:24:39 by maiboyer ### ########.fr */ +/* Updated: 2024/10/23 15:23:27 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -37,8 +37,7 @@ static void _assign_export(t_usize idx, t_str *arg, void *vctx) hmap_env_insert(ctx->state->env, *arg, NULL); key = str_substring(*arg, 0, first_eq - *arg); value = str_substring(first_eq, 1, ~0llu); - if (hmap_env_insert(ctx->state->env, key, value)) - ctx->err = ERROR; + hmap_env_insert(ctx->state->env, key, value); } static t_error handle_quotes(t_str raw, t_string *out) diff --git a/exec/src/run_ast/run_list.c b/exec/src/run_ast/run_list.c index 6d9a74dd..ee2bbb92 100644 --- a/exec/src/run_ast/run_list.c +++ b/exec/src/run_ast/run_list.c @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/09/14 12:34:33 by maiboyer #+# #+# */ -/* Updated: 2024/10/12 17:51:26 by rparodi ### ########.fr */ +/* Updated: 2024/10/23 15:01:54 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -46,12 +46,12 @@ t_error run_list(t_ast_list *list, t_state *state, t_list_result *out) left = -1; right = -1; if (_run_get_exit_code(list->left, state, &left)) - return (ERROR); + left = 127; if ((list->op == AST_LIST_OR && left != 0) || (list->op == AST_LIST_AND && left == 0)) { if (_run_get_exit_code(list->right, state, &right)) - return (ERROR); + right = 127; out->exit = right; } else diff --git a/exec/src/run_ast/run_subshell.c b/exec/src/run_ast/run_subshell.c index 87827d61..8f10b2b2 100644 --- a/exec/src/run_ast/run_subshell.c +++ b/exec/src/run_ast/run_subshell.c @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/09/14 12:35:02 by maiboyer #+# #+# */ -/* Updated: 2024/10/13 17:24:55 by maiboyer ### ########.fr */ +/* Updated: 2024/10/23 15:31:55 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/parser/src/yard/yard.c b/parser/src/yard/yard.c index 049d6961..a11a458e 100644 --- a/parser/src/yard/yard.c +++ b/parser/src/yard/yard.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/07 18:04:13 by rparodi #+# #+# */ -/* Updated: 2024/10/12 17:51:57 by rparodi ### ########.fr */ +/* Updated: 2024/10/23 15:30:59 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -44,8 +44,8 @@ t_error _yard_parenthesis(\ vec_token_pop(stack, &tok); token_free(tok); snode = ast_alloc(AST_SUBSHELL); - vec_ast_pop(output_queue, &tmp); - vec_ast_push(&snode->data.subshell.body, tmp); + if (!vec_ast_pop(output_queue, &tmp)) + vec_ast_push(&snode->data.subshell.body, tmp); vec_ast_push(output_queue, snode); return (NO_ERROR); }