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
template void allocator::deallocate(pointer ptr, size_type n){ if(ptr == nullptr) return ; ::operator delete(ptr); } 在这段代码中ptr是指向连续n个元素内存空间首个元素的指针吗?那么delete(ptr)是只释放了单个元素所在的内存空间还是会全部释放掉,如果只释放单个元素会不会出现内存泄漏问题?
The text was updated successfully, but these errors were encountered:
这里没有问题,因为分配时使用的也是 non-array form ::operator new(n * sizeof(T)),不是 array-form operator new[],因此释放时也是 non-array form。
Sorry, something went wrong.
No branches or pull requests
template
void allocator::deallocate(pointer ptr, size_type n){
if(ptr == nullptr)
return ;
::operator delete(ptr);
}
在这段代码中ptr是指向连续n个元素内存空间首个元素的指针吗?那么delete(ptr)是只释放了单个元素所在的内存空间还是会全部释放掉,如果只释放单个元素会不会出现内存泄漏问题?
The text was updated successfully, but these errors were encountered: