This repository was archived by the owner on Oct 14, 2023. It is now read-only.

Description
在memory/allocate.cpp文件中,Deallocate方法最后删除内存块的代码是不是有问题?感觉好像是在添加新的内存块,没有删除释放的操作。
具体代码如下:
void FreeListAllocate::Deallocate(void *p, int32_t n) {
if (p == nullptr || n == 0) {
logger->error("p cannot be nullptr, n cannot be zero. p={}, n={}", p, n);
return;
}
// 大于MAX_OBJ_SIZE是malloc分配的,也由free回收
if (n > MAX_OBJ_SIZE) {
free(p);
p = nullptr;
return;
}
// 这四行代码感觉好像有问题
auto slot_index = get_index(n);
auto node = static_cast<BlockNode *>(p);
node->next = memory_slot[slot_index];
memory_slot[slot_index] = node;
}