Commit d59edd77 authored by Norby, Tom's avatar Norby, Tom
Browse files

[Fortify] Unique pointer to raw.

parent 8c927e75
Pipeline #100114 failed with stages
in 3 minutes and 18 seconds
...@@ -78,7 +78,7 @@ void ARLDataStream::expand(const std::string& val, ...@@ -78,7 +78,7 @@ void ARLDataStream::expand(const std::string& val,
ARLDataStream::ARLDataStream(const std::string& file, ARLDataStream::ARLDataStream(const std::string& file,
std::ios_base::openmode mode) std::ios_base::openmode mode)
: p(new PImpl(), [](PImpl* impl) { delete impl; }) : p(new PImpl())
{ {
p->file = file; p->file = file;
p->stream = std::make_shared<radix::eafstream>(p->file.c_str(), p->stream = std::make_shared<radix::eafstream>(p->file.c_str(),
...@@ -89,6 +89,8 @@ ARLDataStream::ARLDataStream(const std::string& file, ...@@ -89,6 +89,8 @@ ARLDataStream::ARLDataStream(const std::string& file,
} }
} }
ARLDataStream::~ARLDataStream() { delete p; }
bool ARLDataStream::read_record_header(ARLRecordHeader& rheader) bool ARLDataStream::read_record_header(ARLRecordHeader& rheader)
{ {
bool result = false; bool result = false;
......
...@@ -22,8 +22,7 @@ class RADIX_PUBLIC ARLDataStream ...@@ -22,8 +22,7 @@ class RADIX_PUBLIC ARLDataStream
{ {
// forward declare private implementation // forward declare private implementation
class PImpl; class PImpl;
// unique pointer to private implmentation PImpl* p;
std::unique_ptr<PImpl, void (*)(PImpl*)> p;
private: private:
/** /**
...@@ -46,7 +45,7 @@ class RADIX_PUBLIC ARLDataStream ...@@ -46,7 +45,7 @@ class RADIX_PUBLIC ARLDataStream
public: public:
ARLDataStream() = delete; ARLDataStream() = delete;
ARLDataStream(const std::string& file, std::ios_base::openmode mode); ARLDataStream(const std::string& file, std::ios_base::openmode mode);
~ARLDataStream();
/** /**
* @brief read_index_header Reads a single index header from the stream * @brief read_index_header Reads a single index header from the stream
* @param iheader ARLIndexHeader& * @param iheader ARLIndexHeader&
......
...@@ -110,7 +110,7 @@ eafstream &eafstream::operator>>(float &value) ...@@ -110,7 +110,7 @@ eafstream &eafstream::operator>>(float &value)
eafstream &eafstream::operator>>(std::vector<float> &value) eafstream &eafstream::operator>>(std::vector<float> &value)
{ {
float *tData; float *tData;
tData = readFloatArray((int)value.size()); tData = readFloatArray(value.size());
std::copy(tData, tData + value.size(), value.begin()); std::copy(tData, tData + value.size(), value.begin());
delete[] tData; delete[] tData;
return *this; return *this;
......
...@@ -48,12 +48,12 @@ class F71Case::PImpl ...@@ -48,12 +48,12 @@ class F71Case::PImpl
float flux; float flux;
}; };
F71Case::F71Case() F71Case::F71Case()
: p(new PImpl(), [](PImpl* impl) { delete impl; }) : p(new PImpl())
{ {
} }
F71Case::F71Case(const F71Case& orig) F71Case::F71Case(const F71Case& orig)
: p(new PImpl(), [](PImpl* impl) { delete impl; }) : p(new PImpl())
{ {
p->light_element_nuclides = orig.p->light_element_nuclides; p->light_element_nuclides = orig.p->light_element_nuclides;
p->actinide_nuclides = orig.p->actinide_nuclides; p->actinide_nuclides = orig.p->actinide_nuclides;
...@@ -92,6 +92,8 @@ F71Case::F71Case(const F71Case& orig) ...@@ -92,6 +92,8 @@ F71Case::F71Case(const F71Case& orig)
p->flux = orig.p->flux; p->flux = orig.p->flux;
} }
F71Case::~F71Case() { delete p; }
const std::vector<int>& F71Case::lightElementNuclides() const const std::vector<int>& F71Case::lightElementNuclides() const
{ {
return p->light_element_nuclides; return p->light_element_nuclides;
......
...@@ -76,12 +76,12 @@ class RADIX_PUBLIC F71Case ...@@ -76,12 +76,12 @@ class RADIX_PUBLIC F71Case
{ {
// forward declare private implementation // forward declare private implementation
class PImpl; class PImpl;
// unique pointer to private implmentation PImpl* p;
std::unique_ptr<PImpl, void (*)(PImpl*)> p;
public: public:
F71Case(); F71Case();
F71Case(const F71Case& orig); F71Case(const F71Case& orig);
~F71Case();
const std::vector<int>& lightElementNuclides() const; const std::vector<int>& lightElementNuclides() const;
void setLightElementNuclides(const std::vector<int>& zaids); void setLightElementNuclides(const std::vector<int>& zaids);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment