We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
if (mp->auto_extend) { // 超过总内存限制 if (mp->alloc_mempool_size + total_needed_size > mp->max_mempool_size) { goto err_out; } // 问题1: mem_size_t add_mem_sz = mp->max_mempool_size - mp->mempool_size; // 如果空间足够则按 mempool_size 新增, 不足则分配剩下所有内存 add_mem_sz = add_mem_sz >= mp->mempool_size ? mp->mempool_size : add_mem_sz; if (!extend_memory_list(mp, add_mem_sz)) goto err_out; // 更新实际分配内存 mp->alloc_mempool_size += add_mem_sz; goto FIND_FREE_CHUNK; }
The text was updated successfully, but these errors were encountered:
问题1:是的 问题2:这里实现的很粗糙,内存块的增长只能以mp->mempool_size的整数倍进行,而且只是新增一个块,而不是原地增加,所以剩余可新增内存池大小是这样计算的; 补充:根据前面的判断total_needed_size只能是小于mp->mempool_size的,所以这里就看是可以新增一个mp->mempool_size大小,还是剩下点边角料一起全加了
Sorry, something went wrong.
No branches or pull requests
The text was updated successfully, but these errors were encountered: