From 4235a256400c0f7394d163d61ddf2799d08d3327 Mon Sep 17 00:00:00 2001 From: shassani Date: Thu, 19 Jul 2018 16:00:31 -0700 Subject: [PATCH] Adds ForceStringAlignment to flatbuffers. (#4828) ForceStringAlignment is useful for memory aligning string fields in flatbuffers. --- include/flatbuffers/flatbuffers.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/flatbuffers/flatbuffers.h b/include/flatbuffers/flatbuffers.h index bfcc7d7d5..cb5feaa4f 100644 --- a/include/flatbuffers/flatbuffers.h +++ b/include/flatbuffers/flatbuffers.h @@ -1206,6 +1206,11 @@ class FlatBufferBuilder { void ForceVectorAlignment(size_t len, size_t elemsize, size_t 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