Adds ForceStringAlignment to flatbuffers. (#4828)

ForceStringAlignment is useful for memory aligning string fields in flatbuffers.
This commit is contained in:
shassani 2018-07-19 16:00:31 -07:00 committed by Wouter van Oortmerssen
parent 88cd182349
commit 4235a25640
1 changed files with 5 additions and 0 deletions

View File

@ -1206,6 +1206,11 @@ class FlatBufferBuilder {
void ForceVectorAlignment(size_t len, size_t elemsize, size_t alignment) { void ForceVectorAlignment(size_t len, size_t elemsize, size_t alignment) {
PreAlign(len * elemsize, alignment); PreAlign(len * elemsize, alignment);
} }
// Similar to ForceVectorAlignment but for String fields.
void ForceStringAlignment(size_t len, size_t alignment) {
PreAlign((len + 1) * sizeof(char), alignment);
}
/// @endcond /// @endcond