forked from Bananymous/banan-os
update main #1
|
@ -54,10 +54,12 @@ static bool allocate_pool(size_t pool_index)
|
||||||
assert(pool.start == nullptr);
|
assert(pool.start == nullptr);
|
||||||
|
|
||||||
// allocate memory for pool
|
// allocate memory for pool
|
||||||
pool.start = (uint8_t*)mmap(nullptr, pool.size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
|
void* new_pool = mmap(nullptr, pool.size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
|
||||||
if (pool.start == nullptr)
|
if (new_pool == MAP_FAILED)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
pool.start = (uint8_t*)new_pool;
|
||||||
|
|
||||||
// initialize pool to single unallocated node
|
// initialize pool to single unallocated node
|
||||||
auto* node = (malloc_node_t*)pool.start;
|
auto* node = (malloc_node_t*)pool.start;
|
||||||
node->allocated = false;
|
node->allocated = false;
|
||||||
|
|
|
@ -13,7 +13,7 @@ void* mmap(void* addr, size_t len, int prot, int flags, int fildes, off_t off)
|
||||||
};
|
};
|
||||||
long ret = syscall(SYS_MMAP, &args);
|
long ret = syscall(SYS_MMAP, &args);
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
return nullptr;
|
return MAP_FAILED;
|
||||||
return (void*)ret;
|
return (void*)ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue