mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-28 11:38:05 +00:00
Allow vectors to be aligned beyond their natural type.
Change-Id: I09ade6b688a6b97d65fd832558917225d86c9118
This commit is contained in:
@@ -799,6 +799,15 @@ class FlatBufferBuilder FLATBUFFERS_FINAL_CLASS {
|
|||||||
PreAlign(len * elemsize, elemsize); // Just in case elemsize > uoffset_t.
|
PreAlign(len * elemsize, elemsize); // Just in case elemsize > uoffset_t.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Call this right before StartVector/CreateVector if you want to force the
|
||||||
|
// alignment to be something different than what the element size would
|
||||||
|
// normally dictate.
|
||||||
|
// This is useful when storing a nested_flatbuffer in a vector of bytes,
|
||||||
|
// or when storing SIMD floats, etc.
|
||||||
|
void ForceVectorAlignment(size_t len, size_t elemsize, size_t alignment) {
|
||||||
|
PreAlign(len * elemsize, alignment);
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t *ReserveElements(size_t len, size_t elemsize) {
|
uint8_t *ReserveElements(size_t len, size_t elemsize) {
|
||||||
return buf_.make_space(len * elemsize);
|
return buf_.make_space(len * elemsize);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user