Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

refactor: change the type of prepare_list from raw pointer to std::unique_ptr #1032

Merged
merged 3 commits into from
Jan 21, 2022

Conversation

levy5307
Copy link
Contributor

Use std::unique_ptr to avoid memory leak, for example: L132 in src/replica/split/test/replica_split_test.cpp

apache/incubator-pegasus#887

@@ -129,7 +129,7 @@ class replica_split_test : public replica_test_base
mu->set_logged();
}
}
rep->_prepare_list = _mock_plist;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memory leak in previous implementation

@levy5307 levy5307 closed this Jan 21, 2022
@levy5307 levy5307 reopened this Jan 21, 2022
@levy5307 levy5307 changed the title refactor: change the type of prepare_list to std::unique_ptr refactor: change the type of prepare_list from raw pointer to std::unique_ptr Jan 21, 2022
@@ -149,7 +149,7 @@ class mock_replica : public replica
void set_replica_config(replica_configuration &config) { _config = config; }
void set_partition_status(partition_status::type status) { _config.status = status; }
void set_last_committed_decree(decree d) { _prepare_list->reset(d); }
prepare_list *get_plist() { return _prepare_list; }
prepare_list *get_plist() const { return _prepare_list.get(); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not return unique_ptr directly

@levy5307 levy5307 merged commit 5cc805a into XiaoMi:master Jan 21, 2022
@levy5307 levy5307 deleted the refactor-prepare-list branch January 21, 2022 06:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants