Skip to content
New issue

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

chunk_alloc第二级配置器的问题 #35

Open
ArthurDax opened this issue Oct 9, 2022 · 1 comment
Open

chunk_alloc第二级配置器的问题 #35

ArthurDax opened this issue Oct 9, 2022 · 1 comment

Comments

@ArthurDax
Copy link

if (!start_free){
obj **my_free_list = 0, *p = 0;
for (int i = 0; i <= EMaxBytes::MAXBYTES; i += EAlign::ALIGN){
my_free_list = free_list + FREELIST_INDEX(i);
p = *my_free_list;
if (p != 0){
*my_free_list = p->next;
start_free = (char *)p;
end_free = start_free + i;
return chunk_alloc(bytes, nobjs);
}
}
end_free = 0;
}
heap_size += bytes_to_get;
end_free = start_free + bytes_to_get;

return chunk_alloc(bytes, nobjs);

当第二级配置器无法在free_list中找到空闲内存时,end_free=0,与《STL源码剖析》对比没有
image
这样当无可用内存就不会抛出异常,end_free = start_free + bytes_to_get;,会造成错误的水位标识?

@zouxiaohang
Copy link
Owner

zouxiaohang commented Oct 9, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants