summaryrefslogtreecommitdiff
path: root/src/mem
diff options
context:
space:
mode:
Diffstat (limited to 'src/mem')
-rw-r--r--src/mem/cache/cache_impl.hh2
-rw-r--r--src/mem/packet.cc1
-rw-r--r--src/mem/packet.hh12
3 files changed, 6 insertions, 9 deletions
diff --git a/src/mem/cache/cache_impl.hh b/src/mem/cache/cache_impl.hh
index f4099c0ef..2eb38805c 100644
--- a/src/mem/cache/cache_impl.hh
+++ b/src/mem/cache/cache_impl.hh
@@ -1566,7 +1566,6 @@ doTimingSupplyResponse(PacketPtr req_pkt, const uint8_t *blk_data,
// already made a copy...
PacketPtr pkt = already_copied ? req_pkt : new Packet(req_pkt);
assert(req_pkt->isInvalidate() || pkt->sharedAsserted());
- pkt->allocate();
pkt->makeTimingResponse();
// @todo Make someone pay for this
pkt->firstWordDelay = pkt->lastWordDelay = 0;
@@ -2018,7 +2017,6 @@ Cache<TagStore>::getTimingPacket()
// make copy of current packet to forward, keep current
// copy for response handling
pkt = new Packet(tgt_pkt);
- pkt->allocate();
if (pkt->isWrite()) {
pkt->setData(tgt_pkt->getConstPtr<uint8_t>());
}
diff --git a/src/mem/packet.cc b/src/mem/packet.cc
index 9dd67746b..758770824 100644
--- a/src/mem/packet.cc
+++ b/src/mem/packet.cc
@@ -204,7 +204,6 @@ Packet::checkFunctional(Printable *obj, Addr addr, bool is_secure, int size,
if (isRead()) {
if (func_start >= val_start && func_end <= val_end) {
- allocate();
memcpy(getPtr<uint8_t>(), data + offset, getSize());
return true;
} else {
diff --git a/src/mem/packet.hh b/src/mem/packet.hh
index b540ef6ca..e8fb00680 100644
--- a/src/mem/packet.hh
+++ b/src/mem/packet.hh
@@ -659,6 +659,11 @@ class Packet : public Printable
flags.set(pkt->flags & (VALID_ADDR|VALID_SIZE));
flags.set(pkt->flags & STATIC_DATA);
+
+ // if we did not copy the static data pointer, allocate data
+ // dynamically instead
+ if (!data)
+ allocate();
}
/**
@@ -942,15 +947,10 @@ class Packet : public Printable
data = NULL;
}
- /** If there isn't data in the packet, allocate some. */
+ /** Allocate memory for the packet. */
void
allocate()
{
- if (data) {
- assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA));
- return;
- }
-
assert(flags.noneSet(STATIC_DATA|DYNAMIC_DATA));
flags.set(DYNAMIC_DATA|ARRAY_DATA);
data = new uint8_t[getSize()];