wip fuck it

This commit is contained in:
Maieul BOYER 2024-05-09 19:05:18 +02:00
parent 746a1ad2ad
commit 3937b70957
No known key found for this signature in database
7 changed files with 120 additions and 177 deletions

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/07 09:48:17 by maiboyer #+# #+# */
/* Updated: 2024/05/08 19:15:05 by maiboyer ### ########.fr */
/* Updated: 2024/05/09 13:30:12 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,31 +17,33 @@
#include "me/types.h"
#include <stdalign.h>
#define ARENA_SIZE_DEFAULT 4096 * 2 * 2
#define PAGE_SIZE_DEFAULT 4096 * 4
#define BLOCK_PADDING "\xFE\xDC\xAB\xC0\xFE\xEE"
typedef struct s_arena_block
typedef struct s_mblock
{
t_usize size;
bool end;
bool used;
t_u8 padding[6];
} t_arena_block;
struct s_mblock *next;
struct s_mpage *page;
t_usize size;
bool used;
t_u8 padding[7];
} t_mblock;
typedef struct s_arena_page
typedef struct s_mpage
{
t_usize page_size;
struct s_arena_page *next;
} t_arena_page;
t_usize page_size;
t_mblock *first;
struct s_mpage *next;
} t_mpage;
// Will never be null, as it will allocate a new arena if it needs to do so
t_arena_page *get_head_arena(void);
t_mpage *get_head_arena(void);
// Will return ERROR if it couldn't malloc the page
t_error alloc_arena_page(t_usize min_size, t_arena_page **out);
t_error alloc_arena_page(t_usize min_size, t_mpage **out);
t_error get_block_for_page(t_usize size, t_arena_page *page,
t_arena_block **out);
void print_pages_info(void);
t_arena_page *get_page_from_ptr(void *ptr);
t_mblock *get_block_for_size(t_usize size);
void print_pages_info(void);
t_mpage *get_page_from_ptr(void *ptr);
#endif /* ALLOC_INTERNAL_H */