mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-06 13:37:25 +00:00
Added functionality to obtain a buffer pointer from a root.
Change-Id: Ia63e41d0304e8668ea4ce09a4c31dd999eb96994 Tested: on Linux. Bug: 32218623
This commit is contained in:
@@ -1352,10 +1352,11 @@ CheckedError Parser::ParseDecl() {
|
||||
auto align = static_cast<size_t>(atoi(force_align->constant.c_str()));
|
||||
if (force_align->type.base_type != BASE_TYPE_INT ||
|
||||
align < struct_def->minalign ||
|
||||
align > 16 ||
|
||||
align > FLATBUFFERS_MAX_ALIGNMENT ||
|
||||
align & (align - 1))
|
||||
return Error("force_align must be a power of two integer ranging from the"
|
||||
"struct\'s natural alignment to 16");
|
||||
"struct\'s natural alignment to " +
|
||||
NumToString(FLATBUFFERS_MAX_ALIGNMENT));
|
||||
struct_def->minalign = align;
|
||||
}
|
||||
struct_def->PadLastField(struct_def->minalign);
|
||||
|
||||
@@ -180,7 +180,8 @@ class ResizeContext {
|
||||
// Check if the range between first (lower address) and second straddles
|
||||
// the insertion point. If it does, change the offset at offsetloc (of
|
||||
// type T, with direction D).
|
||||
template<typename T, int D> void Straddle(void *first, void *second,
|
||||
template<typename T, int D> void Straddle(const void *first,
|
||||
const void *second,
|
||||
void *offsetloc) {
|
||||
if (first <= startptr_ && second >= startptr_) {
|
||||
WriteScalar<T>(offsetloc, ReadScalar<T>(offsetloc) + delta_ * D);
|
||||
@@ -194,9 +195,9 @@ class ResizeContext {
|
||||
// resize actually happens.
|
||||
// This must be checked for every offset, since we can't know which offsets
|
||||
// will straddle and which won't.
|
||||
uint8_t &DagCheck(void *offsetloc) {
|
||||
auto dag_idx = reinterpret_cast<uoffset_t *>(offsetloc) -
|
||||
reinterpret_cast<uoffset_t *>(buf_.data());
|
||||
uint8_t &DagCheck(const void *offsetloc) {
|
||||
auto dag_idx = reinterpret_cast<const uoffset_t *>(offsetloc) -
|
||||
reinterpret_cast<const uoffset_t *>(buf_.data());
|
||||
return dag_check_[dag_idx];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user