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
49DataRow::~DataRow()49DataRow::~DataRow()
50{50{
51 for (uint32_t i = 0; i < m_values.size(); i++)51 for (uint32_t i = 0; i < m_values.size(); i++)
52 {52 free(m_values[i]);
53 if (m_values[i])
54 free(m_values[i]);
55 }
56}53}
57 54
58int32_t DataRow::GetColumnIndex(const string& columnName) const55int32_t DataRow::GetColumnIndex(const string& columnName) const
@@ -107,7 +104,10 @@ ValueExpressionPtr DataRow::EvaluateExpression(const DataColumnPtr& column) · 48 unmodified lines
107 const auto expressionTrees = parser->GetExpressionTrees();104 const auto expressionTrees = parser->GetExpressionTrees();
108 105
109 if (expressionTrees.empty())106 if (expressionTrees.empty())
107 {
108 delete parser;
110 throw DataSetException("Expression defined for computed DataColumn \"" + column->Name() + " for table \"" + m_parent->Name() + "\" cannot produce a value");109 throw DataSetException("Expression defined for computed DataColumn \"" + column->Name() + " for table \"" + m_parent->Name() + "\" cannot produce a value");
110 }
111 111
112 m_values[columnIndex] = parser;112 m_values[columnIndex] = parser;
113 113
@@ -176,7 +176,7 @@ void DataRow::SetValue(int32_t columnIndex, const Nullable<T>& value, DataType t · 62 unmodified lines
176 if (value.HasValue())176 if (value.HasValue())
177 {177 {
178 uint8_t* copy = static_cast<uint8_t*>(malloc(sizeof(T)));178 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
180 m_values[columnIndex] = copy;180 m_values[columnIndex] = copy;
181 }181 }
182 else182 else
@@ -321,7 +321,7 @@ void DataRow::SetBooleanValue(int32_t columnIndex, const Nullable<bool>& value) · 138 unmodified lines
321 if (value.HasValue())321 if (value.HasValue())
322 {322 {
323 uint8_t* copy = static_cast<uint8_t*>(malloc(1));323 uint8_t* copy = static_cast<uint8_t*>(malloc(1));
324 *copy = value.GetValueOrDefault() ? 1 : 0;324 *copy = value.GetValueOrDefault() ? 1 : 0; //-V522
325 m_values[columnIndex] = copy;325 m_values[columnIndex] = copy;
326 }326 }
327 else327 else
@@ -465,7 +465,7 @@ void DataRow::SetGuidValue(int32_t columnIndex, const Nullable<GSF::Guid>& value · 137 unmodified lines
465 if (value.HasValue())465 if (value.HasValue())
466 {466 {
467 int8_t* copy = static_cast<int8_t*>(malloc(16));467 int8_t* copy = static_cast<int8_t*>(malloc(16));
468 memcpy(copy, value.GetValueOrDefault().data, 16);468 memcpy(copy, value.GetValueOrDefault().data, 16); //-V575
469 m_values[columnIndex] = copy;469 m_values[columnIndex] = copy;
470 }470 }
471 else471 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