mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 12:05:50 +00:00
Replace deprecated Vector::Length() with Vector::size() (#5131)
- enable FLATBUFFERS_ATTRIBUTE if C++17 or higher
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
3f388ec747
commit
fcacb46d01
@@ -299,13 +299,13 @@ class ResizeContext {
|
||||
void SetString(const reflection::Schema &schema, const std::string &val,
|
||||
const String *str, std::vector<uint8_t> *flatbuf,
|
||||
const reflection::Object *root_table) {
|
||||
auto delta = static_cast<int>(val.size()) - static_cast<int>(str->Length());
|
||||
auto delta = static_cast<int>(val.size()) - static_cast<int>(str->size());
|
||||
auto str_start = static_cast<uoffset_t>(
|
||||
reinterpret_cast<const uint8_t *>(str) - vector_data(*flatbuf));
|
||||
auto start = str_start + static_cast<uoffset_t>(sizeof(uoffset_t));
|
||||
if (delta) {
|
||||
// Clear the old string, since we don't want parts of it remaining.
|
||||
memset(vector_data(*flatbuf) + start, 0, str->Length());
|
||||
memset(vector_data(*flatbuf) + start, 0, str->size());
|
||||
// Different size, we must expand (or contract).
|
||||
ResizeContext(schema, start, delta, flatbuf, root_table);
|
||||
// Set the new length.
|
||||
|
||||
Reference in New Issue
Block a user