mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-01-10 06:28:03 -05:00
Fix a couple of potentially uninitialized arrays
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <algorithm> // For max
|
||||
#include <numeric>
|
||||
#include <cmath>
|
||||
#include <array>
|
||||
#include "PlatformDetermination.h"
|
||||
#include "CPstrings.h"
|
||||
#include "Exceptions.h"
|
||||
@@ -21,6 +22,13 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
template <typename T, size_t N>
|
||||
std::array<T, N> create_filled_array(T value) {
|
||||
std::array<T, N> arr;
|
||||
arr.fill(value);
|
||||
return arr;
|
||||
}
|
||||
|
||||
inline bool ValidNumber(double x) {
|
||||
// Idea from http://www.johndcook.com/IEEE_exceptions_in_cpp.html
|
||||
return (x <= DBL_MAX && x >= -DBL_MAX);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <array>
|
||||
#include "CoolPropTools.h"
|
||||
#include "DataStructures.h"
|
||||
#include "CPnumerics.h"
|
||||
|
||||
namespace CoolProp {
|
||||
|
||||
@@ -147,11 +148,14 @@ public:
|
||||
|
||||
template<int N>
|
||||
class CacheArray{
|
||||
|
||||
private:
|
||||
|
||||
std::size_t inext = 0;
|
||||
std::array<double, N> m_values;
|
||||
std::array<bool, N> m_cached;
|
||||
public:
|
||||
std::array<double, N> m_values = create_filled_array<double, N>(_HUGE);
|
||||
std::array<bool, N> m_cached = create_filled_array<bool, N>(false);
|
||||
|
||||
public:
|
||||
void clear(){
|
||||
memset(m_values.data(), 0, sizeof(m_values));
|
||||
memset(m_cached.data(), false, sizeof(m_cached));
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "CachedElement.h"
|
||||
#include "Backends/Cubics/GeneralizedCubic.h"
|
||||
#include "crossplatform_shared_ptr.h"
|
||||
#include "CPnumerics.h"
|
||||
|
||||
#if ENABLE_CATCH
|
||||
# include "MultiComplex/MultiComplex.hpp"
|
||||
@@ -740,8 +741,8 @@ class ResidualHelmholtzSAFTAssociating : public BaseHelmholtzTerm
|
||||
class BaseHelmholtzContainer
|
||||
{
|
||||
protected:
|
||||
std::array<double, 16> cache;
|
||||
std::array<bool, 16> is_cached;
|
||||
std::array<double, 16> cache = create_filled_array<double, N>(_HUGE);
|
||||
std::array<bool, 16> is_cached = create_filled_array<bool, N>(false);
|
||||
constexpr static std::size_t i00 = 0, i01 = 1, i02 = 2, i03 = 3, i04 = 4,
|
||||
i10 = 5, i11 = 6, i12 = 7, i13 = 8,
|
||||
i20 = 9, i21 = 10, i22 = 11,
|
||||
|
||||
Reference in New Issue
Block a user