Made a memory allocator (crude)
This commit is contained in:
parent
b5c7344851
commit
941bac31b6
53 changed files with 469 additions and 146 deletions
20
stdme/src/os/abort.c
Normal file
20
stdme/src/os/abort.c
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* abort.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/07 11:08:03 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/05/07 13:09:59 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "me/alloc/alloc_internal.h"
|
||||
#include "me/types.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
void me_abort(void)
|
||||
{
|
||||
me_exit(1);
|
||||
}
|
||||
30
stdme/src/os/exit.c
Normal file
30
stdme/src/os/exit.c
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* exit.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/07 13:08:52 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/05/07 15:01:38 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "me/types.h"
|
||||
#include "me/alloc/alloc_internal.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
void me_exit(t_i32 exit_code)
|
||||
{
|
||||
t_arena_page *arena;
|
||||
t_arena_page *tmp;
|
||||
|
||||
arena = get_head_arena();
|
||||
while (arena)
|
||||
{
|
||||
tmp = arena->next;
|
||||
free(arena);
|
||||
arena = tmp;
|
||||
}
|
||||
exit(exit_code);
|
||||
}
|
||||
|
|
@ -73,8 +73,8 @@ t_error in_path(t_spawn_info *info, t_process *process, t_const_str path,
|
|||
}
|
||||
sp_index = 0;
|
||||
while (splitted_path[sp_index])
|
||||
free(splitted_path[sp_index++]);
|
||||
free(splitted_path);
|
||||
me_free(splitted_path[sp_index++]);
|
||||
me_free(splitted_path);
|
||||
return (NO_ERROR);
|
||||
}
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ t_error find_binary(t_spawn_info *info, t_process *process)
|
|||
}
|
||||
if (access(s.buf, X_OK | R_OK) == 0)
|
||||
{
|
||||
free(info->binary_path);
|
||||
me_free(info->binary_path);
|
||||
info->binary_path = s.buf;
|
||||
return (NO_ERROR);
|
||||
}
|
||||
|
|
@ -117,7 +117,7 @@ static void cleanup(t_spawn_info info, t_process *process, bool cleanup_process)
|
|||
close(info.stderr.vals.fd.value);
|
||||
vec_str_free(info.arguments);
|
||||
vec_str_free(info.environement);
|
||||
free(info.binary_path);
|
||||
me_free(info.binary_path);
|
||||
}
|
||||
|
||||
t_error spawn_process(t_spawn_info info, t_process *process)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue