@@ -342,8 +342,6 @@ class FilePicker {
342
342
};
343
343
} // anonymous namespace
344
344
345
- VersionStorageInfo::~VersionStorageInfo () { delete[] (files_ - 1 ); }
346
-
347
345
Version::~Version () {
348
346
assert (refs_ == 0 );
349
347
@@ -1174,7 +1172,7 @@ VersionStorageInfo::VersionStorageInfo(
1174
1172
num_non_empty_levels_(0 ),
1175
1173
file_indexer_(user_comparator),
1176
1174
compaction_style_(compaction_style),
1177
- files_(new std::vector<FileMetaData*>[ num_levels_ + 1 ] ),
1175
+ files_(num_levels_),
1178
1176
base_level_(num_levels_ == 1 ? -1 : 1 ),
1179
1177
level_multiplier_(0.0 ),
1180
1178
files_by_compaction_pri_(num_levels_),
@@ -1196,9 +1194,7 @@ VersionStorageInfo::VersionStorageInfo(
1196
1194
is_pick_compaction_fail(false ),
1197
1195
is_pick_garbage_collection_fail(false ),
1198
1196
force_consistency_checks_(_force_consistency_checks),
1199
- blob_marked_for_compaction_(false ) {
1200
- ++files_; // level -1 used for dependence files
1201
- }
1197
+ blob_marked_for_compaction_(false ) {}
1202
1198
1203
1199
Version::Version (ColumnFamilyData* column_family_data, VersionSet* vset,
1204
1200
const EnvOptions& env_opt,
@@ -4046,9 +4042,7 @@ Status VersionSet::ReduceNumberOfLevels(const std::string& dbname,
4046
4042
// we need to allocate an array with the old number of levels size to
4047
4043
// avoid SIGSEGV in WriteSnapshot()
4048
4044
// however, all levels bigger or equal to new_levels will be empty
4049
- std::vector<FileMetaData*>* new_files_list =
4050
- new std::vector<FileMetaData*>[current_levels + 1 ];
4051
- ++new_files_list;
4045
+ VersionStorageInfo::Files new_files_list (current_levels);
4052
4046
for (int i = -1 ; i < new_levels - 1 ; i++) {
4053
4047
new_files_list[i] = vstorage->LevelFiles (i);
4054
4048
}
@@ -4057,8 +4051,7 @@ Status VersionSet::ReduceNumberOfLevels(const std::string& dbname,
4057
4051
new_files_list[new_levels - 1 ] = vstorage->LevelFiles (first_nonempty_level);
4058
4052
}
4059
4053
4060
- delete[] (vstorage->files_ - 1 );
4061
- vstorage->files_ = new_files_list;
4054
+ vstorage->files_ = std::move (new_files_list);
4062
4055
vstorage->num_levels_ = new_levels;
4063
4056
4064
4057
MutableCFOptions mutable_cf_options (*options);
0 commit comments