Made FlexBuffers reuse tracker track types

This commit is contained in:
Wouter van Oortmerssen
2021-12-14 10:00:56 -08:00
parent a22b1b6267
commit f8148b8dad
4 changed files with 54 additions and 42 deletions

View File

@@ -35,7 +35,8 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
num_tables_(0),
max_tables_(_max_tables),
upper_bound_(0),
check_alignment_(_check_alignment) {
check_alignment_(_check_alignment),
flex_reuse_tracker_(nullptr) {
FLATBUFFERS_ASSERT(size_ < FLATBUFFERS_MAX_BUFFER_SIZE);
}
@@ -254,7 +255,13 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
// clang-format on
}
std::vector<bool> &GetReuseVector() { return reuse_tracker_; }
std::vector<uint8_t> *GetFlexReuseTracker() {
return flex_reuse_tracker_;
}
void SetFlexReuseTracker(std::vector<uint8_t> *rt) {
flex_reuse_tracker_ = rt;
}
private:
const uint8_t *buf_;
@@ -265,9 +272,7 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
uoffset_t max_tables_;
mutable size_t upper_bound_;
bool check_alignment_;
// This is here for nested FlexBuffers, cheap if not touched.
// TODO: allow user to supply memory for this.
std::vector<bool> reuse_tracker_;
std::vector<uint8_t> *flex_reuse_tracker_;
};
} // namespace flatbuffers