From ad3f75dc81efc8818786c32d6190e3ed069b9fc6 Mon Sep 17 00:00:00 2001 From: Andreas Hansson Date: Thu, 16 Oct 2014 05:49:46 -0400 Subject: dev: Use shared_ptr for EthPacketData This patch transitions the EthPacketData from the ad-hoc RefCountingPtr to the c++11 shared_ptr. There are no changes in behaviour, and the code modifications are mainly replacing "new" with "make_shared". The bool casting operator for the shared_ptr is explicit, and we must therefore either cast it, compare it to NULL (p != nullptr), double negate it (!!p) or do a (p ? true : false). --- src/dev/i8254xGBe.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/dev/i8254xGBe.cc') diff --git a/src/dev/i8254xGBe.cc b/src/dev/i8254xGBe.cc index d86d7b486..af9734761 100644 --- a/src/dev/i8254xGBe.cc +++ b/src/dev/i8254xGBe.cc @@ -41,6 +41,7 @@ */ #include +#include #include "base/inet.hh" #include "base/trace.hh" @@ -2147,7 +2148,7 @@ IGbE::txStateMachine() } if (!txPacket) { - txPacket = new EthPacketData(16384); + txPacket = std::make_shared(16384); } if (!txDescCache.packetWaiting()) { @@ -2469,7 +2470,7 @@ IGbE::serialize(std::ostream &os) rxFifo.serialize("rxfifo", os); txFifo.serialize("txfifo", os); - bool txPktExists = txPacket; + bool txPktExists = txPacket != nullptr; SERIALIZE_SCALAR(txPktExists); if (txPktExists) txPacket->serialize("txpacket", os); @@ -2526,7 +2527,7 @@ IGbE::unserialize(Checkpoint *cp, const std::string §ion) bool txPktExists; UNSERIALIZE_SCALAR(txPktExists); if (txPktExists) { - txPacket = new EthPacketData(16384); + txPacket = std::make_shared(16384); txPacket->unserialize("txpacket", cp, section); } -- cgit v1.2.3