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