summaryrefslogtreecommitdiff
path: root/src/dev/ns_gige.cc
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2014-10-16 05:49:46 -0400
committerAndreas Hansson <andreas.hansson@arm.com>2014-10-16 05:49:46 -0400
commitad3f75dc81efc8818786c32d6190e3ed069b9fc6 (patch)
treef3f0e2a55a3fbcd554fb8d4f110e41991de03ae9 /src/dev/ns_gige.cc
parent4e67ab6663f8f4960a1078546906746877f87e1a (diff)
downloadgem5-ad3f75dc81efc8818786c32d6190e3ed069b9fc6.tar.xz
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).
Diffstat (limited to 'src/dev/ns_gige.cc')
-rw-r--r--src/dev/ns_gige.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/dev/ns_gige.cc b/src/dev/ns_gige.cc
index f180b0ecd..239babe70 100644
--- a/src/dev/ns_gige.cc
+++ b/src/dev/ns_gige.cc
@@ -34,6 +34,7 @@
* DP83820 ethernet controller. Does not support priority queueing
*/
#include <deque>
+#include <memory>
#include <string>
#include "base/debug.hh"
@@ -51,6 +52,7 @@
// clang complains about std::set being overloaded with Packet::set if
// we open up the entire namespace std
+using std::make_shared;
using std::min;
using std::ostream;
using std::string;
@@ -1676,7 +1678,7 @@ NSGigE::txKick()
case txFifoBlock:
if (!txPacket) {
DPRINTF(EthernetSM, "****starting the tx of a new packet****\n");
- txPacket = new EthPacketData(16384);
+ txPacket = make_shared<EthPacketData>(16384);
txPacketBufPtr = txPacket->data;
}
@@ -2185,7 +2187,7 @@ NSGigE::serialize(ostream &os)
/*
* Serialize the various helper variables
*/
- bool txPacketExists = txPacket;
+ bool txPacketExists = txPacket != nullptr;
SERIALIZE_SCALAR(txPacketExists);
if (txPacketExists) {
txPacket->length = txPacketBufPtr - txPacket->data;
@@ -2194,7 +2196,7 @@ NSGigE::serialize(ostream &os)
SERIALIZE_SCALAR(txPktBufPtr);
}
- bool rxPacketExists = rxPacket;
+ bool rxPacketExists = rxPacket != nullptr;
SERIALIZE_SCALAR(rxPacketExists);
if (rxPacketExists) {
rxPacket->serialize("rxPacket", os);
@@ -2352,7 +2354,7 @@ NSGigE::unserialize(Checkpoint *cp, const std::string &section)
bool txPacketExists;
UNSERIALIZE_SCALAR(txPacketExists);
if (txPacketExists) {
- txPacket = new EthPacketData(16384);
+ txPacket = make_shared<EthPacketData>(16384);
txPacket->unserialize("txPacket", cp, section);
uint32_t txPktBufPtr;
UNSERIALIZE_SCALAR(txPktBufPtr);
@@ -2364,7 +2366,7 @@ NSGigE::unserialize(Checkpoint *cp, const std::string &section)
UNSERIALIZE_SCALAR(rxPacketExists);
rxPacket = 0;
if (rxPacketExists) {
- rxPacket = new EthPacketData(16384);
+ rxPacket = make_shared<EthPacketData>(16384);
rxPacket->unserialize("rxPacket", cp, section);
uint32_t rxPktBufPtr;
UNSERIALIZE_SCALAR(rxPktBufPtr);