History

TimeSeriesPlatformLibrary: Minor code optimizations and cleanup per PVS-Studio analysis.

J. Ritchie Carroll committed 7 years ago

Commit c36ddbf1 parent 4a5df8a14 files · +391 −93Browse files

Showing the changes to Source/Libraries/TimeSeriesPlatformLibrary/Data/DataRow.cpp (1 of 14 files). Show all

Unified · Split

Source/Libraries/TimeSeriesPlatformLibrary/Data/DataRow.cpp+7−7
@@ -49,10 +49,7 @@ DataRow::DataRow(DataTablePtr parent) : · 48 unmodified lines
4949 DataRow::~DataRow()
5050 {
5151 for (uint32_t i = 0; i < m_values.size(); i++)
52− {
53− if (m_values[i])
54− free(m_values[i]);
55− }
52+ free(m_values[i]);
5653 }
5754
5855 int32_t DataRow::GetColumnIndex(const string& columnName) const
@@ -107,7 +104,10 @@ ValueExpressionPtr DataRow::EvaluateExpression(const DataColumnPtr& column) · 48 unmodified lines
107104 const auto expressionTrees = parser->GetExpressionTrees();
108105
109106 if (expressionTrees.empty())
107+ {
108+ delete parser;
110109 throw DataSetException("Expression defined for computed DataColumn \"" + column->Name() + " for table \"" + m_parent->Name() + "\" cannot produce a value");
110+ }
111111
112112 m_values[columnIndex] = parser;
113113
@@ -176,7 +176,7 @@ void DataRow::SetValue(int32_t columnIndex, const Nullable<T>& value, DataType t · 62 unmodified lines
176176 if (value.HasValue())
177177 {
178178 uint8_t* copy = static_cast<uint8_t*>(malloc(sizeof(T)));
179− memcpy(copy, &value.Value, sizeof(T));
179+ memcpy(copy, &value.Value, sizeof(T)); //-V575
180180 m_values[columnIndex] = copy;
181181 }
182182 else
@@ -321,7 +321,7 @@ void DataRow::SetBooleanValue(int32_t columnIndex, const Nullable<bool>& value) · 138 unmodified lines
321321 if (value.HasValue())
322322 {
323323 uint8_t* copy = static_cast<uint8_t*>(malloc(1));
324− *copy = value.GetValueOrDefault() ? 1 : 0;
324+ *copy = value.GetValueOrDefault() ? 1 : 0; //-V522
325325 m_values[columnIndex] = copy;
326326 }
327327 else
@@ -465,7 +465,7 @@ void DataRow::SetGuidValue(int32_t columnIndex, const Nullable<GSF::Guid>& value · 137 unmodified lines
465465 if (value.HasValue())
466466 {
467467 int8_t* copy = static_cast<int8_t*>(malloc(16));
468− memcpy(copy, value.GetValueOrDefault().data, 16);
468+ memcpy(copy, value.GetValueOrDefault().data, 16); //-V575
469469 m_values[columnIndex] = copy;
470470 }
471471 else

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t