移除分配器allocate函数不需要的align参数

This commit is contained in:
pointer-to-bios 2024-02-13 01:01:59 +08:00
parent d14187ea96
commit 7e22dd604f
3 changed files with 9 additions and 9 deletions

View File

@ -23,7 +23,7 @@
/* 只分配不映射空间 */ /* 只分配不映射空间 */
#define MEMM_ALLOC_ONLY_MEMORY (128 * 1024 * 1024) #define MEMM_ALLOC_ONLY_MEMORY (128 * 1024 * 1024)
typedef void *(*memm_allocate_t)(void *allocator, usize size, usize align); typedef void *(*memm_allocate_t)(void *allocator, usize size);
typedef void (*memm_free_t)(void *allocator, void *mem); typedef void (*memm_free_t)(void *allocator, void *mem);
/* /*

View File

@ -13,7 +13,7 @@ void raw_allocator_new(raw_allocator_t *allocator, usize size)
allocator->cells[0].length = 0; allocator->cells[0].length = 0;
} }
void *raw_allocator_allocate(raw_allocator_t *allocator, usize size, usize align) void *raw_allocator_allocate(raw_allocator_t *allocator, usize size)
{ {
usize real_size = size; usize real_size = size;
align_to(real_size, 16); align_to(real_size, 16);

View File

@ -24,7 +24,7 @@ mem_manager_t *memm_new(usize mem_size)
MEMM_RAW_ALLOCATOR, 0); MEMM_RAW_ALLOCATOR, 0);
allocator_iterator_t *alcatr_ind = allocator0->allocate( allocator_iterator_t *alcatr_ind = allocator0->allocate(
&allocator0->allocator_instance, sizeof(allocator_iterator_t), 0); &allocator0->allocator_instance, sizeof(allocator_iterator_t));
alcatr_ind->allocator = allocator0; alcatr_ind->allocator = allocator0;
alcatr_ind->left = nullptr; alcatr_ind->left = nullptr;
@ -37,7 +37,7 @@ mem_manager_t *memm_new(usize mem_size)
align_to(pmc_size, 8); align_to(pmc_size, 8);
pmc_size /= 8; pmc_size /= 8;
memory_manager.page_map = allocator0->allocate(&allocator0->allocator_instance, pmc_size, 0); memory_manager.page_map = allocator0->allocate(&allocator0->allocator_instance, pmc_size);
memset(memory_manager.page_map, 0, pmc_size); memset(memory_manager.page_map, 0, pmc_size);
memset(memory_manager.page_map, 0xff, MEMM_ALLOC_ONLY_MEMORY / MEMM_PAGE_SIZE / 8); memset(memory_manager.page_map, 0xff, MEMM_ALLOC_ONLY_MEMORY / MEMM_PAGE_SIZE / 8);
for (usize i = (MEMM_ALLOC_ONLY_MEMORY / MEMM_PAGE_SIZE / 8) * (u8)8; for (usize i = (MEMM_ALLOC_ONLY_MEMORY / MEMM_PAGE_SIZE / 8) * (u8)8;
@ -48,7 +48,7 @@ mem_manager_t *memm_new(usize mem_size)
// 配置分配器页地图 // 配置分配器页地图
memory_manager.map_with_allocator = memory_manager.map_with_allocator =
allocator0->allocate(&allocator0->allocator_instance, pmc_size, 0); allocator0->allocate(&allocator0->allocator_instance, pmc_size);
memset(memory_manager.map_with_allocator, 0, pmc_size); memset(memory_manager.map_with_allocator, 0, pmc_size);
for (usize i = kernel_initial_size / MEMM_PAGE_SIZE; for (usize i = kernel_initial_size / MEMM_PAGE_SIZE;
i < MEMM_ALLOC_ONLY_MEMORY / MEMM_PAGE_SIZE; i < MEMM_ALLOC_ONLY_MEMORY / MEMM_PAGE_SIZE;
@ -59,7 +59,7 @@ mem_manager_t *memm_new(usize mem_size)
// 分配器释放页地图 // 分配器释放页地图
memory_manager.map_with_destructed_allocator = memory_manager.map_with_destructed_allocator =
allocator0->allocate(&allocator0->allocator_instance, pmc_size, 0); allocator0->allocate(&allocator0->allocator_instance, pmc_size);
memset(memory_manager.map_with_destructed_allocator, 0, pmc_size); memset(memory_manager.map_with_destructed_allocator, 0, pmc_size);
// 配置空闲页线段搜索表 // 配置空闲页线段搜索表
@ -103,14 +103,14 @@ void *memm_find_and_allocate(allocator_iterator_t *allocator_ind, usize size, us
allocator_t *allocator = allocator_ind->allocator; allocator_t *allocator = allocator_ind->allocator;
if (allocator->pid == pid && allocator->full == false) if (allocator->pid == pid && allocator->full == false)
{ // 尝试用本节点分配 { // 尝试用本节点分配
if ((ptr = allocator->allocate(&allocator->allocator_instance, size, 0)) != nullptr) if ((ptr = allocator->allocate(&allocator->allocator_instance, size)) != nullptr)
{ {
*writeback = allocator; *writeback = allocator;
return ptr; return ptr;
} }
else else
{ {
if ((ptr = allocator->allocate(&allocator->allocator_instance, 0, 0)) == nullptr) if ((ptr = allocator->allocate(&allocator->allocator_instance, 0)) == nullptr)
allocator->full = true; allocator->full = true;
} }
} }
@ -197,7 +197,7 @@ void *memm_allocate(usize size, usize pid)
allind->left = nullptr; allind->left = nullptr;
allind->right = nullptr; allind->right = nullptr;
insert_allocator(memory_manager.allocators, allind); insert_allocator(memory_manager.allocators, allind);
ptr = new_allocator->allocate(&new_allocator->allocator_instance, orgsize, 0); ptr = new_allocator->allocate(&new_allocator->allocator_instance, orgsize);
after_allocation: after_allocation:
if (ptr != nullptr) if (ptr != nullptr)