diff options
author | Giacomo Travaglini <giacomo.travaglini@arm.com> | 2018-06-04 09:40:19 +0100 |
---|---|---|
committer | Giacomo Travaglini <giacomo.travaglini@arm.com> | 2018-06-11 16:55:30 +0000 |
commit | f54020eb8155371725ab75b0fc5c419287eca084 (patch) | |
tree | 65d379f7603e689e083e9a58ff4c2e90abd19fbf /ext/sst | |
parent | 2113b21996d086dab32b9fd388efe3df241bfbd2 (diff) | |
download | gem5-f54020eb8155371725ab75b0fc5c419287eca084.tar.xz |
misc: Using smart pointers for memory Requests
This patch is changing the underlying type for RequestPtr from Request*
to shared_ptr<Request>. Having memory requests being managed by smart
pointers will simplify the code; it will also prevent memory leakage and
dangling pointers.
Change-Id: I7749af38a11ac8eb4d53d8df1252951e0890fde3
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/10996
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
Diffstat (limited to 'ext/sst')
-rw-r--r-- | ext/sst/ExtMaster.cc | 3 | ||||
-rw-r--r-- | ext/sst/ExtSlave.cc | 5 |
2 files changed, 4 insertions, 4 deletions
diff --git a/ext/sst/ExtMaster.cc b/ext/sst/ExtMaster.cc index 24682485f..3afd6b444 100644 --- a/ext/sst/ExtMaster.cc +++ b/ext/sst/ExtMaster.cc @@ -171,7 +171,7 @@ ExtMaster::handleEvent(SST::Event* event) cmdO = MemCmd::StoreCondReq; } - auto req = new Request(ev->getAddr(), ev->getSize(), flags, 0); + auto req = std::make_shared<Request>(ev->getAddr(), ev->getSize(), flags, 0); req->setContext(ev->getGroupId()); auto pkt = new Packet(req, cmdO); @@ -205,7 +205,6 @@ ExtMaster::recvTimingResp(PacketPtr pkt) { // copy the payload and then destroy gem5 packet resp->setPayload(pkt->getSize(), pkt->getPtr<uint8_t>()); - delete pkt->req; delete pkt; nic->send(resp); diff --git a/ext/sst/ExtSlave.cc b/ext/sst/ExtSlave.cc index 6251ba8d9..0e2f8b438 100644 --- a/ext/sst/ExtSlave.cc +++ b/ext/sst/ExtSlave.cc @@ -128,7 +128,6 @@ ExtSlave::recvTimingReq(PacketPtr pkt) if (simPhase == INIT) { link->sendInitData(ev); - delete pkt->req; delete pkt; } else { if (pkt->needsResponse()) { @@ -176,7 +175,9 @@ ExtSlave::handleEvent(Event* ev) // make Req/Pkt for Snoop/no response needed // presently no consideration for masterId, packet type, flags... - RequestPtr req = new Request(event->getAddr(), event->getSize(), 0, 0); + RequestPtr req = std::make_shared<Request>( + event->getAddr(), event->getSize(), 0, 0); + auto pkt = new Packet(req, ::MemCmd::InvalidateReq); // Clear out bus delay notifications |