Skip to content

Commit

Permalink
Use resize(0) to reset all properties since initProperties() can be c…
Browse files Browse the repository at this point in the history
…alled multiple times
  • Loading branch information
knro committed Aug 9, 2024
1 parent c9fb77d commit ced1037
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions libs/indibase/indiinputinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void InputInterface::initProperties(const char *groupName, uint8_t digital, uint
{
m_DigitalLabelConfig = false;
m_AnalogLabelConfig = false;
DigitalInputLabelsTP.reserve(digital);
DigitalInputLabelsTP.resize(0);
// Digital labels
for (size_t i = 0; i < digital; i++)
{
Expand All @@ -68,7 +68,7 @@ void InputInterface::initProperties(const char *groupName, uint8_t digital, uint
}

// Analog labels
AnalogInputLabelsTP.reserve(analog);
AnalogInputLabelsTP.resize(0);
for (size_t i = 0; i < analog; i++)
{
auto name = "ANALOG_INPUT_" + std::to_string(i + 1);
Expand All @@ -88,7 +88,7 @@ void InputInterface::initProperties(const char *groupName, uint8_t digital, uint
}

// Analog inputs
AnalogInputsNP.reserve(analog);
AnalogInputsNP.resize(0);
for (size_t i = 0; i < analog; i++)
{
auto name = "ANALOG_INPUT_" + std::to_string(i + 1);
Expand All @@ -103,7 +103,7 @@ void InputInterface::initProperties(const char *groupName, uint8_t digital, uint
AnalogInputsNP.push_back(std::move(oneNumber));
}

DigitalInputsSP.reserve(digital);
DigitalInputsSP.resize(0);
// Initialize switches, use labels if loaded.
for (size_t i = 0; i < digital; i++)
{
Expand Down
4 changes: 2 additions & 2 deletions libs/indibase/indioutputinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ OutputInterface::~OutputInterface()
/////////////////////////////////////////////////////////////////////////////////////////////
void OutputInterface::initProperties(const char *groupName, uint8_t Outputs, const std::string &prefix)
{
DigitalOutputLabelsTP.reserve(Outputs);
DigitalOutputLabelsTP.resize(0);

// Initialize labels
for (auto i = 0; i < Outputs; i++)
Expand All @@ -62,7 +62,7 @@ void OutputInterface::initProperties(const char *groupName, uint8_t Outputs, con
DigitalOutputLabelsTP.shrink_to_fit();
DigitalOutputLabelsTP.load();

DigitalOutputsSP.reserve(Outputs);
DigitalOutputsSP.resize(0);
// Initialize switches, use labels if loaded.
for (size_t i = 0; i < Outputs; i++)
{
Expand Down

0 comments on commit ced1037

Please sign in to comment.