summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/storage_block-inl.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/disk_cache/storage_block-inl.h')
-rw-r--r--net/disk_cache/storage_block-inl.h20
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__