@@ -91,9 +91,9 @@ namespace pcpp
9191 m_PfRingVersion = readPfRingVersion (ring.get ());
9292 PCPP_LOG_DEBUG (" PF_RING version is: " << m_PfRingVersion);
9393 }
94- std::unique_ptr<PfRingDevice> newDev =
95- std::unique_ptr<PfRingDevice>(new PfRingDevice (currInterface->name ));
96- m_PfRingDeviceList. push_back (std::move (newDev));
94+
95+ auto newDev = std::unique_ptr<PfRingDevice>(new PfRingDevice (currInterface->name ));
96+ m_DeviceList. pushBack (std::move (newDev));
9797 PCPP_LOG_DEBUG (" Found interface: " << currInterface->name );
9898 }
9999 }
@@ -106,25 +106,23 @@ namespace pcpp
106106 PCPP_LOG_DEBUG (" PfRingDeviceList init end" );
107107
108108 // Full update of all elements of the view vector to synchronize them with the main vector.
109- m_PfRingDeviceListView.resize (m_PfRingDeviceList.size ());
110- std::transform (m_PfRingDeviceList.begin (), m_PfRingDeviceList.end (), m_PfRingDeviceListView.begin (),
111- [](const std::unique_ptr<PfRingDevice>& ptr) { return ptr.get (); });
109+ m_PfRingDeviceListView.resize (m_DeviceList.size ());
110+ std::copy (m_DeviceList.begin (), m_DeviceList.end (), m_PfRingDeviceListView.begin ());
112111 }
113112
114113 PfRingDevice* PfRingDeviceList::getPfRingDeviceByName (const std::string& devName) const
115114 {
116115 PCPP_LOG_DEBUG (" Searching all live devices..." );
117- auto devIter = std::find_if (
118- m_PfRingDeviceList.begin (), m_PfRingDeviceList.end (),
119- [&devName](const std::unique_ptr<PfRingDevice>& dev) { return dev->getDeviceName () == devName; });
116+ auto devIter = std::find_if (m_DeviceList.begin (), m_DeviceList.end (),
117+ [&devName](PfRingDevice const * dev) { return dev->getDeviceName () == devName; });
120118
121- if (devIter == m_PfRingDeviceList .end ())
119+ if (devIter == m_DeviceList .end ())
122120 {
123121 PCPP_LOG_DEBUG (" Found no PF_RING devices with name '" << devName << " '" );
124122 return nullptr ;
125123 }
126124
127- return devIter-> get () ;
125+ return * devIter;
128126 }
129127} // namespace pcpp
130128
0 commit comments