TinySTL
TinySTL copied to clipboard
chunk_alloc第二级配置器的问题
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源码剖析》对比没有
这样当无可用内存就不会抛出异常,end_free = start_free + bytes_to_get;,会造成错误的水位标识?
邹晓航已经收到了你发送的邮件~~