diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-19 22:35:47 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-19 22:35:47 +0000 |
commit | 2b2d8447b83112a01dd61c2979b683a699d3d775 (patch) | |
tree | 94581a6f652dd119771156d2b8ecb27e82e199c1 /net/disk_cache/storage_block-inl.h | |
parent | 51fff29dc2dae1a8be5ea107d2b13205510c4e46 (diff) | |
download | chromium_src-2b2d8447b83112a01dd61c2979b683a699d3d775.zip chromium_src-2b2d8447b83112a01dd61c2979b683a699d3d775.tar.gz chromium_src-2b2d8447b83112a01dd61c2979b683a699d3d775.tar.bz2 |
Use appropriate version of delete in storage block
depending on how storage was allocated.
B=5041
Review URL: http://codereview.chromium.org/15032/show
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7324 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/storage_block-inl.h')
-rw-r--r-- | net/disk_cache/storage_block-inl.h | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/net/disk_cache/storage_block-inl.h b/net/disk_cache/storage_block-inl.h index 890954e..2082b0a 100644 --- a/net/disk_cache/storage_block-inl.h +++ b/net/disk_cache/storage_block-inl.h @@ -23,8 +23,7 @@ template<typename T> StorageBlock<T>::StorageBlock(MappedFile* file, 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> bool StorageBlock<T>::LazyInit(MappedFile* file, 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 @@ template<typename T> void StorageBlock<T>::AllocateData() { 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__ |