non-generic version of CreateUninitializedVector for c ffi

Change-Id: Id7618e53797a158b82e7e480a6507887db3528bc
This commit is contained in:
dyu 2014-12-27 21:30:26 +08:00 committed by Wouter van Oortmerssen
parent ae1763e226
commit 6f4b4c80a7
1 changed files with 8 additions and 4 deletions

View File

@ -649,11 +649,15 @@ class FlatBufferBuilder FLATBUFFERS_FINAL_CLASS {
// Specialized version for non-copying use cases. Data to be written later.
// After calling this function, GetBufferPointer() can be cast to the
// corresponding Vector<> type to write the data (through Data()).
template<typename T> Offset<Vector<T>> CreateUninitializedVector(size_t len) {
uoffset_t CreateUninitializedVector(size_t len, size_t elemsize) {
NotNested();
StartVector(len, sizeof(T));
buf_.make_space(len * sizeof(T));
return Offset<Vector<T>>(EndVector(len));
StartVector(len, elemsize);
buf_.make_space(len * elemsize);
return EndVector(len);
}
template<typename T> Offset<Vector<T>> CreateUninitializedVector(size_t len) {
return CreateUninitializedVector(len, sizeof(T));
}
template<typename T> Offset<Vector<T>> CreateVector(const std::vector<T> &v){