add malloc(ft_malloc for now) function

This commit is contained in:
2024-11-29 18:49:10 +01:00
parent f721d2e95d
commit 2a3d29eb36
3 changed files with 117 additions and 42 deletions

View File

@ -6,27 +6,24 @@
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/26 16:38:01 by tomoron #+# #+# */
/* Updated: 2024/11/28 20:16:54 by tomoron ### ########.fr */
/* Updated: 2024/11/29 18:45:50 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MALLOC_H
# define MALLOC_H
# ifndef DEBUG
# define DEBUG 1
# endif
#include <stddef.h>
#include <sys/mman.h>
#include <unistd.h>
#define TINY_MALLOC_ALL 16384
#define SMALL_MALLOC_ALL 524288
#define TINY_BLOC_SIZE 16384
#define SMALL_BLOC_SIZE 524288
#define TINY_MALLOC 1024
#define SMALL_MALLOC 4096
typedef struct s_alloc
{
size_t size; //8
@ -35,7 +32,7 @@ typedef struct s_alloc
typedef struct s_mem_bloc
{
t_alloc *first_alloc; //8
size_t space_left; //8
struct s_mem_bloc *next; //8
} t_mem_bloc; //size 16
@ -46,6 +43,9 @@ typedef struct s_allocations
t_mem_bloc *large;
} t_allocations;
t_allocations g_allocs;
extern t_allocations g_allocs;
void *ft_malloc(size_t size);