Skip to content

Commit

Permalink
Removed unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisn committed Feb 12, 2023
1 parent 5780c77 commit 4d6b912
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 32 deletions.
32 changes: 3 additions & 29 deletions Src/SerialPortList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ SerialPortList::SerialPortList()

//------------------------------------------------------------------------------

SerialPortList::~SerialPortList()
{
}

//------------------------------------------------------------------------------

void SerialPortList::Clear()
{
m_PortArray.clear();
Expand Down Expand Up @@ -111,26 +105,6 @@ const SerialPortInfo& SerialPortList::GetPortInfo(int Index) const

//------------------------------------------------------------------------------

// Returns the index of a serial port, given the port name.

int SerialPortList::Find(const std::string& strPortName) const
{
int Index = -1;

auto it = std::find_if(m_PortArray.begin(), m_PortArray.end(), [strPortName](const SerialPortInfo& Info) {
return _stricmp(strPortName.c_str(), Info.strPortName.c_str()) == 0;
});

if (it != m_PortArray.end())
{
Index = std::distance(m_PortArray.begin(), it);
}

return Index;
}

//------------------------------------------------------------------------------

// Determines whether the supplied string is a valid serial port name, i.e.,
// has a name of the form COMx.

Expand Down Expand Up @@ -300,7 +274,7 @@ static BOOL GetDeviceProperty(
bSuccess = FALSE;
}

delete[] pData;
delete [] pData;
}
else
{
Expand Down Expand Up @@ -345,7 +319,7 @@ bool SerialPortList::BuildPortList()

if (bSuccess)
{
pGUIDArray = new GUID[RequiredSize];
pGUIDArray = new(std::nothrow) GUID[RequiredSize];

if (pGUIDArray != nullptr)
{
Expand Down Expand Up @@ -463,7 +437,7 @@ bool SerialPortList::BuildPortList()

if (pGUIDArray != nullptr)
{
delete[] pGUIDArray;
delete [] pGUIDArray;
}

// Sort the list by ascending COM port name.
Expand Down
3 changes: 0 additions & 3 deletions Src/SerialPortList.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,13 @@ class SerialPortList
{
public:
SerialPortList();
~SerialPortList();

SerialPortList(const SerialPortList&) = delete;
SerialPortList& operator=(const SerialPortList&) = delete;

public:
bool BuildPortList();
int GetPortCount() const;
const SerialPortInfo& GetPortInfo(int Index) const;
int Find(const std::string& strPortName) const;

private:
void Clear();
Expand Down

0 comments on commit 4d6b912

Please sign in to comment.