Put the custom allocator in its own lib, as to lessen the difficulty to switch between libc's allocator and a custom one (#7)
This commit is contained in:
parent
713f0f0302
commit
cb7f3c3fdf
85 changed files with 1121 additions and 877 deletions
42
allocator/include/aq/allocator.h
Normal file
42
allocator/include/aq/allocator.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* allocator.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/14 17:52:31 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/05/14 17:55:36 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef ALLOCATOR_H
|
||||
#define ALLOCATOR_H
|
||||
|
||||
#include "me/types.h"
|
||||
|
||||
typedef struct s_allocator t_allocator;
|
||||
|
||||
typedef void *(*t_allocator_alloc)(t_allocator *self, t_usize size);
|
||||
typedef void *(*t_allocator_alloc_array)(t_allocator *self, t_usize size,
|
||||
t_usize count);
|
||||
typedef void *(*t_allocator_realloc)(t_allocator *self, void *ptr,
|
||||
t_usize requested_size);
|
||||
typedef void *(*t_allocator_realloc_array)(t_allocator *self, void *ptr,
|
||||
t_usize requested_size,
|
||||
t_usize requested_count);
|
||||
typedef void (*t_allocator_free)(t_allocator *self, void *ptr);
|
||||
typedef void (*t_allocator_uninit)(t_allocator *self);
|
||||
|
||||
struct s_allocator
|
||||
{
|
||||
t_allocator_alloc alloc;
|
||||
t_allocator_alloc_array alloc_array;
|
||||
t_allocator_realloc realloc;
|
||||
t_allocator_realloc_array realloc_array;
|
||||
t_allocator_free free;
|
||||
t_allocator_uninit uninit;
|
||||
void *alloc_data;
|
||||
};
|
||||
|
||||
#endif /* ALLOCATOR_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue