Fixed bugs that could cause struct values not to be stored or misaligned

Change-Id: Ie36fe581c000fa4571c96fafd39a9e12fa29e1ca
Tested: on Linux
This commit is contained in:
Wouter van Oortmerssen
2014-08-11 17:38:54 -07:00
parent d8a173ddc7
commit be3c874258
2 changed files with 8 additions and 3 deletions

View File

@@ -603,7 +603,7 @@ class FlatBufferBuilder {
template<typename T> Offset<Vector<const T *>> CreateVectorOfStructs(
const T *v, size_t len) {
NotNested();
StartVector(len, AlignOf<T>());
StartVector(len * sizeof(T) / AlignOf<T>(), AlignOf<T>());
PushBytes(reinterpret_cast<const uint8_t *>(v), sizeof(T) * len);
return Offset<Vector<const T *>>(EndVector(len));
}