Hello, I am working on a slab allocator for a school project.
I got to the point of getting a memory zone, the size of that memory zone is a multiple of sysconf(_SC_PAGESIZE).
t_zone *new_zone;
new_zone = mmap(NULL, size, PROT_READ | PROT_WRITE, \
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (new_zone == MAP_FAILED)
{
ft_putstr_fd("mmap() returned MAP_FAILED\n", 2);
return NULL;
}
int test = alignof(t_zone);
(void)test;
ft_memset(new_zone, 0, sizeof(t_zone));
new_zone->size_total = size;
new_zone->size_available = size - sizeof(t_zone);
add_page_to_global(size, new_zone, *zones);
return new_zone;
With s_zone :
struct s_zone {
t_zone *prev;
t_zone *next;
size_t size_total;
size_t size_available;
t_block *blocks;
};
What I don't get is, where can I actually start storing data ? and where my first block of "user data" should be in this. I have this little drawing I made that I think is how it is represented.
.