summaryrefslogtreecommitdiff
path: root/issues/issue320_test.cc
diff options
context:
space:
mode:
authorChris Mumford <cmumford@google.com>2019-04-11 19:47:16 -0700
committerChris Mumford <cmumford@google.com>2019-04-12 00:17:13 -0700
commit08e771901f454ac32643bd8e8cb2bcfa08026c0c (patch)
tree6e77115ac776c447f4201bbe6bad61ae7d140f6b /issues/issue320_test.cc
parent65e86f75ea30e44bc65327f92a16328684269acb (diff)
downloadleveldb-08e771901f454ac32643bd8e8cb2bcfa08026c0c.tar.gz
Simplify issue320_test.
Use std::unique_ptr to simplify issue320_test. PiperOrigin-RevId: 243190799
Diffstat (limited to 'issues/issue320_test.cc')
-rw-r--r--issues/issue320_test.cc13
1 files changed, 3 insertions, 10 deletions
diff --git a/issues/issue320_test.cc b/issues/issue320_test.cc
index 28ef1b8..5145857 100644
--- a/issues/issue320_test.cc
+++ b/issues/issue320_test.cc
@@ -45,7 +45,8 @@ TEST(Issue320, Test) {
bool delete_before_put = false;
bool keep_snapshots = true;
- std::vector<std::pair<std::string, std::string>*> test_map(10000, nullptr);
+ std::vector<std::unique_ptr<std::pair<std::string, std::string>>> test_map(
+ 10000);
std::vector<Snapshot const*> snapshots(100, nullptr);
DB* db;
@@ -73,7 +74,7 @@ TEST(Issue320, Test) {
if (test_map[index] == nullptr) {
num_items++;
- test_map[index] = new std::pair<std::string, std::string>(
+ test_map[index] = std::make_unique<std::pair<std::string, std::string>>(
CreateRandomString(index), CreateRandomString(index));
batch.Put(test_map[index]->first, test_map[index]->second);
} else {
@@ -90,7 +91,6 @@ TEST(Issue320, Test) {
if (num_items >= target_size && GenerateRandomNumber(100) > 30) {
batch.Delete(test_map[index]->first);
- delete test_map[index];
test_map[index] = nullptr;
--num_items;
} else {
@@ -117,13 +117,6 @@ TEST(Issue320, Test) {
}
}
- for (size_t i = 0; i < test_map.size(); ++i) {
- if (test_map[i] != nullptr) {
- delete test_map[i];
- test_map[i] = nullptr;
- }
- }
-
delete db;
DestroyDB(dbpath, options);
}