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/etherlink.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/dev/etherlink.cc') diff --git a/src/dev/etherlink.cc b/src/dev/etherlink.cc index 0117bb7c2..c5ef66d99 100644 --- a/src/dev/etherlink.cc +++ b/src/dev/etherlink.cc @@ -195,7 +195,7 @@ EtherLink::Link::transmit(EthPacketPtr pkt) void EtherLink::Link::serialize(const string &base, ostream &os) { - bool packet_exists = packet; + bool packet_exists = packet != nullptr; paramOut(os, base + ".packet_exists", packet_exists); if (packet_exists) packet->serialize(base + ".packet", os); @@ -216,7 +216,7 @@ EtherLink::Link::unserialize(const string &base, Checkpoint *cp, bool packet_exists; paramIn(cp, section, base + ".packet_exists", packet_exists); if (packet_exists) { - packet = new EthPacketData(16384); + packet = make_shared(16384); packet->unserialize(base + ".packet", cp, section); } @@ -273,7 +273,7 @@ LinkDelayEvent::unserialize(Checkpoint *cp, const string §ion, link = parent->link[number]; - packet = new EthPacketData(16384); + packet = make_shared(16384); packet->unserialize("packet", cp, section); } -- cgit v1.2.3