summaryrefslogtreecommitdiffstats
path: root/net/disk_cache
diff options
context:
space:
mode:
Diffstat (limited to 'net/disk_cache')
-rw-r--r--net/disk_cache/storage_block-inl.h20
-rw-r--r--net/disk_cache/storage_block.h1
2 files changed, 15 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__
diff --git a/net/disk_cache/storage_block.h b/net/disk_cache/storage_block.h
index b43d746..30e0bf9 100644
--- a/net/disk_cache/storage_block.h
+++ b/net/disk_cache/storage_block.h
@@ -63,6 +63,7 @@ class StorageBlock : public FileBlock {
private:
void AllocateData();
+ void DeleteData();
T* data_;
MappedFile* file_;