summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mem/cache/base.cc4
-rw-r--r--src/mem/cache/blk.hh11
2 files changed, 10 insertions, 5 deletions
diff --git a/src/mem/cache/base.cc b/src/mem/cache/base.cc
index 862aa3a94..a0614100f 100644
--- a/src/mem/cache/base.cc
+++ b/src/mem/cache/base.cc
@@ -113,8 +113,7 @@ BaseCache::BaseCache(const BaseCacheParams *p, unsigned blk_size)
// forward snoops is overridden in init() once we can query
// whether the connected master is actually snooping or not
- tempBlock = new TempCacheBlk();
- tempBlock->data = new uint8_t[blkSize];
+ tempBlock = new TempCacheBlk(blkSize);
tags->setCache(this);
if (prefetcher)
@@ -123,7 +122,6 @@ BaseCache::BaseCache(const BaseCacheParams *p, unsigned blk_size)
BaseCache::~BaseCache()
{
- delete [] tempBlock->data;
delete tempBlock;
}
diff --git a/src/mem/cache/blk.hh b/src/mem/cache/blk.hh
index 97e1d42d9..3bb0317cc 100644
--- a/src/mem/cache/blk.hh
+++ b/src/mem/cache/blk.hh
@@ -406,10 +406,17 @@ class TempCacheBlk final : public CacheBlk
Addr _addr;
public:
- TempCacheBlk() : CacheBlk() {}
+ /**
+ * Creates a temporary cache block, with its own storage.
+ * @param size The size (in bytes) of this cache block.
+ */
+ TempCacheBlk(unsigned size) : CacheBlk()
+ {
+ data = new uint8_t[size];
+ }
TempCacheBlk(const TempCacheBlk&) = delete;
TempCacheBlk& operator=(const TempCacheBlk&) = delete;
- ~TempCacheBlk() {};
+ ~TempCacheBlk() { delete [] data; };
/**
* Invalidate the block and clear all state.