update: changed some stuff

This commit is contained in:
maix0 2024-10-23 15:36:18 +02:00
parent 78b9506885
commit cfbb84c028
10 changed files with 31 additions and 51 deletions

View file

@ -3,7 +3,6 @@ lc_alloc/functions1 \
lc_alloc/functions2 \ lc_alloc/functions2 \
me_alloc/find_block \ me_alloc/find_block \
me_alloc/functions1 \ me_alloc/functions1 \
me_alloc/functions2 \
me_alloc/internals \ me_alloc/internals \
me_alloc/merge_blocks \ me_alloc/merge_blocks \
me_alloc/pages \ me_alloc/pages \

View file

@ -14,39 +14,39 @@
#include "aq/libc_wrapper.h" #include "aq/libc_wrapper.h"
#include "me/types.h" #include "me/types.h"
void *__libc_malloc(t_usize size); void *malloc(t_usize size);
void *__libc_calloc(t_usize size, t_usize elem); void *calloc(t_usize size, t_usize elem);
void *__libc_realloc(void *ptr, t_usize size); void *realloc(void *ptr, t_usize size);
void *__libc_reallocarray(void *ptr, t_usize size, t_usize elem); void *reallocarray(void *ptr, t_usize size, t_usize elem);
void __libc_free(void *ptr); void free(void *ptr);
void *lc_malloc(t_allocator *self, t_usize size) void *lc_malloc(t_allocator *self, t_usize size)
{ {
(void)(self); (void)(self);
return (__libc_malloc(size)); return (malloc(size));
} }
void *lc_calloc(t_allocator *self, t_usize size, t_usize elem) void *lc_calloc(t_allocator *self, t_usize size, t_usize elem)
{ {
(void)(self); (void)(self);
return (__libc_calloc(size, elem)); return (calloc(size, elem));
} }
void *lc_realloc(t_allocator *self, void *ptr, t_usize size) void *lc_realloc(t_allocator *self, void *ptr, t_usize size)
{ {
(void)(self); (void)(self);
return (__libc_realloc(ptr, size)); return (realloc(ptr, size));
} }
void *lc_realloc_array(t_allocator *self, void *ptr, t_usize size, void *lc_realloc_array(t_allocator *self, void *ptr, t_usize size,
t_usize elem) t_usize elem)
{ {
(void)(self); (void)(self);
return (__libc_reallocarray(ptr, size, elem)); return (reallocarray(ptr, size, elem));
} }
void lc_free(t_allocator *self, void *ptr) void lc_free(t_allocator *self, void *ptr)
{ {
(void)(self); (void)(self);
return (__libc_free(ptr)); return (free(ptr));
} }

View file

@ -18,8 +18,8 @@
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
void *__libc_malloc(t_usize size); void *malloc(t_usize size);
void __libc_free(void *ptr); void free(void *ptr);
void *m_malloc(struct s_allocator_melloc *self, t_usize size) 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) if (list->pages[idx].data != NULL)
{ {
vg_mempool_free(list, list->pages[idx].data); 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].size = 0;
list->pages[idx].data = NULL; list->pages[idx].data = NULL;
} }
idx++; idx++;
} }
list_next = list->next; list_next = list->next;
(__libc_free(list), vg_mempool_destroy(list), \ (free(list), vg_mempool_destroy(list), \
vg_mem_no_access(list, sizeof(*list))); vg_mem_no_access(list, sizeof(*list)));
list = list_next; list = list_next;
} }

View file

@ -1,19 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* functions2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
// }

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */ /* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/10 16:51:10 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 "me/types.h"
#include <errno.h> #include <errno.h>
void *__libc_malloc(t_usize size); void *malloc(t_usize size);
void __libc_free(void *ptr); void free(void *ptr);
t_error alloc_page_list(t_page_list **out) 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) if (out == NULL)
return (ERROR); return (ERROR);
val = __libc_malloc(sizeof(*val)); val = malloc(sizeof(*val));
if (val == NULL) if (val == NULL)
return (ERROR); return (ERROR);
mem_set_zero(val, sizeof(*val)); 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) if (list == NULL)
return (ERROR); return (ERROR);
vg_mem_defined(list, sizeof(*list)); vg_mem_defined(list, sizeof(*list));
list->pages[list->len].data = __libc_malloc(page_size); list->pages[list->len].data = malloc(page_size);
mem_set_zero(list->pages[list->len].data, page_size);
if (list->pages[list->len].data == NULL) if (list->pages[list->len].data == NULL)
return (ERROR); return (ERROR);
mem_set_zero(list->pages[list->len].data, page_size);
list->pages[list->len].size = page_size; list->pages[list->len].size = page_size;
vg_mempool_alloc(list, list->pages[list->len].data, page_size); vg_mempool_alloc(list, list->pages[list->len].data, page_size);
chunk = get_first_block(&list->pages[list->len]); chunk = get_first_block(&list->pages[list->len]);

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */ /* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/17 21:43:33 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 ; continue ;
vec_str_push(&ret, str_clone(entry->d_name)); vec_str_push(&ret, str_clone(entry->d_name));
} }
close_dir(tmp);
return (*out = ret, NO_ERROR); return (*out = ret, NO_ERROR);
} }

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */ /* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/07 14:13:41 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); hmap_env_insert(ctx->state->env, *arg, NULL);
key = str_substring(*arg, 0, first_eq - *arg); key = str_substring(*arg, 0, first_eq - *arg);
value = str_substring(first_eq, 1, ~0llu); value = str_substring(first_eq, 1, ~0llu);
if (hmap_env_insert(ctx->state->env, key, value)) hmap_env_insert(ctx->state->env, key, value);
ctx->err = ERROR;
} }
static t_error handle_quotes(t_str raw, t_string *out) static t_error handle_quotes(t_str raw, t_string *out)

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */ /* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/14 12:34:33 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; left = -1;
right = -1; right = -1;
if (_run_get_exit_code(list->left, state, &left)) 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 if ((list->op == AST_LIST_OR && left != 0) || (list->op == AST_LIST_AND
&& left == 0)) && left == 0))
{ {
if (_run_get_exit_code(list->right, state, &right)) if (_run_get_exit_code(list->right, state, &right))
return (ERROR); right = 127;
out->exit = right; out->exit = right;
} }
else else

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */ /* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/14 12:35:02 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 */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */ /* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/07 18:04:13 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); vec_token_pop(stack, &tok);
token_free(tok); token_free(tok);
snode = ast_alloc(AST_SUBSHELL); snode = ast_alloc(AST_SUBSHELL);
vec_ast_pop(output_queue, &tmp); if (!vec_ast_pop(output_queue, &tmp))
vec_ast_push(&snode->data.subshell.body, tmp); vec_ast_push(&snode->data.subshell.body, tmp);
vec_ast_push(output_queue, snode); vec_ast_push(output_queue, snode);
return (NO_ERROR); return (NO_ERROR);
} }