Fixed possible alignment issue in Java

Tested: on Linux

Change-Id: Ie80aa19ed13ac4fa15cd3fd768f1a35526bdc607
This commit is contained in:
Wouter van Oortmerssen
2014-08-13 11:43:15 -07:00
parent f2908b7787
commit cdb0dca39d
3 changed files with 18 additions and 10 deletions

View File

@@ -123,10 +123,11 @@ public class FlatBufferBuilder {
putInt(off);
}
public void startVector(int elem_size, int num_elems) {
public void startVector(int elem_size, int num_elems, int alignment) {
notNested();
vector_num_elems = num_elems;
prep(SIZEOF_INT, elem_size * num_elems);
prep(alignment, elem_size * num_elems); // Just in case alignment > int.
}
public int endVector() {
@@ -137,7 +138,7 @@ public class FlatBufferBuilder {
public int createString(String s) {
byte[] utf8 = s.getBytes(utf8charset);
addByte((byte)0);
startVector(1, utf8.length);
startVector(1, utf8.length, 1);
System.arraycopy(utf8, 0, bb.array(), space -= utf8.length, utf8.length);
return endVector();
}