Skip to content

Commit

Permalink
Avoid using references to hold pointers
Browse files Browse the repository at this point in the history
Using a reference to keep a smart pointer around is bad because doing so
prevents the reference-counting mechanism from working.  This should not
be an issue in the remaining cases fixed here, but a different instance
fixed in the parent commit caused issues with the previous fix itself.
Better fix them all for consistency.
  • Loading branch information
jmmv committed Jul 11, 2016
1 parent 1ac9eda commit 342b4a4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions drivers/run_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ start_test(scheduler::scheduler_handle& handle,
const config::tree& user_config,
drivers::run_tests::base_hooks& hooks)
{
const model::test_program_ptr& test_program = match.first;
const model::test_program_ptr test_program = match.first;
const std::string& test_case_name = match.second;

hooks.got_test_case(*test_program, test_case_name);
Expand Down Expand Up @@ -289,7 +289,7 @@ drivers::run_tests::drive(const fs::path& kyuafile_path,
optional< engine::scan_result > match = scanner.yield();
if (!match)
break;
const model::test_program_ptr& test_program = match.get().first;
const model::test_program_ptr test_program = match.get().first;
const std::string& test_case_name = match.get().second;

const model::test_case& test_case = test_program->find(
Expand Down
2 changes: 1 addition & 1 deletion engine/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ struct test_exec_data : public exec_data {
/// \param user_config_ User configuration passed to the test.
test_exec_data(const model::test_program_ptr test_program_,
const std::string& test_case_name_,
const std::shared_ptr< scheduler::interface >& interface_,
const std::shared_ptr< scheduler::interface > interface_,
const config::tree& user_config_) :
exec_data(test_program_, test_case_name_),
interface(interface_), user_config(user_config_)
Expand Down
2 changes: 1 addition & 1 deletion utils/format/containers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ template< typename T1, typename T2 >
std::ostream& operator<<(std::ostream&, const std::pair< T1, T2 >&);

template< typename T >
std::ostream& operator<<(std::ostream&, const std::shared_ptr< T >&);
std::ostream& operator<<(std::ostream&, const std::shared_ptr< T >);

template< typename T >
std::ostream& operator<<(std::ostream&, const std::set< T >&);
Expand Down
2 changes: 1 addition & 1 deletion utils/format/containers.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ std::operator<<(std::ostream& output, const std::pair< T1, T2 >& object)
/// \return The output stream.
template< typename T >
std::ostream&
std::operator<<(std::ostream& output, const std::shared_ptr< T >& object)
std::operator<<(std::ostream& output, const std::shared_ptr< T > object)
{
if (object.get() == NULL) {
output << "<NULL>";
Expand Down

0 comments on commit 342b4a4

Please sign in to comment.