mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-01-14 04:01:55 -06:00
Avoid memory leak from the *unique_ptr<X>.release() antipattern.
This commit is contained in:
parent
c84f14042d
commit
6a7e1e08c0
@ -174,8 +174,8 @@ public:
|
||||
const UDQState& udqState() const
|
||||
{ return *udqState_; }
|
||||
|
||||
WellTestState transferWTestState() {
|
||||
return *this->wtestState_.release();
|
||||
std::unique_ptr<WellTestState> transferWTestState() {
|
||||
return std::move(this->wtestState_);
|
||||
}
|
||||
|
||||
|
||||
|
@ -186,7 +186,7 @@ getWellEcl(const std::string& well_name) const
|
||||
template<class Scalar>
|
||||
void BlackoilWellModelGeneric<Scalar>::
|
||||
initFromRestartFile(const RestartValue& restartValues,
|
||||
WellTestState wtestState,
|
||||
std::unique_ptr<WellTestState> wtestState,
|
||||
const std::size_t numCells,
|
||||
bool handle_ms_well)
|
||||
{
|
||||
|
@ -156,7 +156,7 @@ public:
|
||||
const SummaryState& st);
|
||||
|
||||
void initFromRestartFile(const RestartValue& restartValues,
|
||||
WellTestState wtestState,
|
||||
std::unique_ptr<WellTestState> wtestState,
|
||||
const std::size_t numCells,
|
||||
bool handle_ms_well);
|
||||
|
||||
|
@ -46,10 +46,10 @@ serializationTestObject(const ParallelWellInfo<Scalar>& pinfo)
|
||||
}
|
||||
|
||||
template<class Scalar>
|
||||
void WGState<Scalar>::wtest_state(WellTestState wtest_state)
|
||||
void WGState<Scalar>::wtest_state(std::unique_ptr<WellTestState> wtest_state)
|
||||
{
|
||||
wtest_state.filter_wells( this->well_state.wells() );
|
||||
this->well_test_state = std::move(wtest_state);
|
||||
wtest_state->filter_wells( this->well_state.wells() );
|
||||
this->well_test_state = std::move(*wtest_state);
|
||||
}
|
||||
|
||||
template<class Scalar>
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include <opm/simulators/wells/GroupState.hpp>
|
||||
#include <opm/input/eclipse/Schedule/Well/WellTestState.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
template<class Scalar> class ParallelWellInfo;
|
||||
@ -41,7 +43,7 @@ struct WGState
|
||||
|
||||
static WGState serializationTestObject(const ParallelWellInfo<Scalar>& pinfo);
|
||||
|
||||
void wtest_state(WellTestState wtest_state);
|
||||
void wtest_state(std::unique_ptr<WellTestState> wtest_state);
|
||||
|
||||
WellState<Scalar> well_state;
|
||||
GroupState<Scalar> group_state;
|
||||
|
Loading…
Reference in New Issue
Block a user