added std::vector<V> instead of V* (#5902)
This commit is contained in:
parent
28039d39a1
commit
0126ecb3e2
1 changed files with 7 additions and 6 deletions
|
@ -5,6 +5,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <vector>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
|
||||||
// defined in Version.cpp
|
// defined in Version.cpp
|
||||||
|
@ -66,7 +67,7 @@ public:
|
||||||
// good header, read some key/value pairs
|
// good header, read some key/value pairs
|
||||||
K key;
|
K key;
|
||||||
|
|
||||||
V* value = nullptr;
|
std::vector<V> value;
|
||||||
u32 value_size;
|
u32 value_size;
|
||||||
u32 entry_number;
|
u32 entry_number;
|
||||||
|
|
||||||
|
@ -78,13 +79,13 @@ public:
|
||||||
if (next_extent > file_size)
|
if (next_extent > file_size)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
delete[] value;
|
value.clear();
|
||||||
value = new V[value_size];
|
value.resize(value_size);
|
||||||
|
|
||||||
// read key/value and pass to reader
|
// read key/value and pass to reader
|
||||||
if (Read(&key) && Read(value, value_size) && Read(&entry_number) &&
|
if (Read(&key) && Read(value.data(), value_size) && Read(&entry_number) &&
|
||||||
entry_number == m_num_entries + 1) {
|
entry_number == m_num_entries + 1) {
|
||||||
reader.Read(key, value, value_size);
|
reader.Read(key, value.data(), value_size);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +96,7 @@ public:
|
||||||
m_file.seekp(last_pos);
|
m_file.seekp(last_pos);
|
||||||
m_file.clear();
|
m_file.clear();
|
||||||
|
|
||||||
delete[] value;
|
value.clear();
|
||||||
return m_num_entries;
|
return m_num_entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue