Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(563)

Unified Diff: net/disk_cache/storage_block-inl.h

Issue 15032: Use appropriate version of delete in storage block... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/disk_cache/storage_block.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/storage_block-inl.h
===================================================================
--- net/disk_cache/storage_block-inl.h (revision 7294)
+++ net/disk_cache/storage_block-inl.h (working copy)
@@ -23,8 +23,7 @@
template<typename T> StorageBlock<T>::~StorageBlock() {
if (modified_)
Store();
- if (own_data_)
- delete data_;
+ DeleteData();
}
template<typename T> void* StorageBlock<T>::buffer() const {
@@ -58,10 +57,7 @@
template<typename T> void StorageBlock<T>::SetData(T* other) {
DCHECK(!modified_);
- if (own_data_) {
- delete data_;
- own_data_ = false;
- }
+ DeleteData();
data_ = other;
}
@@ -122,6 +118,18 @@
own_data_ = true;
}
+template<typename T> void StorageBlock<T>::DeleteData() {
+ if (own_data_) {
+ if (!extended_) {
+ delete data_;
+ } else {
+ data_->~T();
+ delete[] reinterpret_cast<char*>(data_);
+ }
+ own_data_ = false;
+ }
+}
+
} // namespace disk_cache
#endif // NET_DISK_CACHE_CACHE_INTERNAL_INL_H__
« no previous file with comments | « net/disk_cache/storage_block.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698