Kernel: We add FixedWidthAllocators on demand

On SYS_ALLOC we will add a new FixedWidthAllocator if the old ones
are already full or we don't have one with proper size. This allows
arbitary number of allocations as long as you have enough memory
available :)

Next I will be writing a general allocator for allocations larger
than 4096 bytes which should make SYS_ALLOC syscall complete :)
This commit is contained in:
Bananymous
2023-05-07 23:57:01 +03:00
parent 05046d6e93
commit b0ec0f1a1a
5 changed files with 77 additions and 27 deletions

View File

@@ -1,25 +1,34 @@
#include <stdio.h>
#include <stdlib.h>
#define N 512
int main()
{
for (int i = 0; i < 10; i++)
for (int i = 0; i <= 10; i++)
{
int* ptrs[10];
for (int j = 0; j < 10; j++)
int** ptrs = malloc(N * sizeof(int*));
if (ptrs == NULL)
{
ptrs[j] = malloc(10);
perror("malloc");
return 1;
}
for (int j = 0; j < N; j++)
{
ptrs[j] = malloc(sizeof(int));
if (ptrs[j] == NULL)
{
perror("malloc");
return 1;
}
*ptrs[j] = j;
putc('0' + *ptrs[j], stdout);
putchar('0' + *ptrs[j] % 10);
}
for (int j = 0; j < 10; j++)
putchar('\n');
for (int j = 0; j < N; j++)
free(ptrs[j]);
putc('\n', stdout);
free(ptrs);
}
return 0;