mirror of
https://github.com/Lime3DS/Lime3DS
synced 2024-10-30 11:47:51 +00:00
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
|
||||
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include "common/common_types.h"
|
||||
|
||||
// defined in Version.cpp
|
||||
|
@ -66,7 +67,7 @@ public:
|
|||
// good header, read some key/value pairs
|
||||
K key;
|
||||
|
||||
V* value = nullptr;
|
||||
std::vector<V> value;
|
||||
u32 value_size;
|
||||
u32 entry_number;
|
||||
|
||||
|
@ -78,13 +79,13 @@ public:
|
|||
if (next_extent > file_size)
|
||||
break;
|
||||
|
||||
delete[] value;
|
||||
value = new V[value_size];
|
||||
value.clear();
|
||||
value.resize(value_size);
|
||||
|
||||
// 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) {
|
||||
reader.Read(key, value, value_size);
|
||||
reader.Read(key, value.data(), value_size);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
@ -95,7 +96,7 @@ public:
|
|||
m_file.seekp(last_pos);
|
||||
m_file.clear();
|
||||
|
||||
delete[] value;
|
||||
value.clear();
|
||||
return m_num_entries;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue