non-generic version of CreateUninitializedVector for c ffi
authordyu <david.yu.ftw@gmail.com>
Sat, 27 Dec 2014 13:30:26 +0000 (21:30 +0800)
committerWouter van Oortmerssen <wvo@google.com>
Wed, 7 Jan 2015 18:47:26 +0000 (10:47 -0800)
Change-Id: Id7618e53797a158b82e7e480a6507887db3528bc

include/flatbuffers/flatbuffers.h

index 7b72319..e1999f9 100644 (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){