mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 04:04:19 +00:00
Made CreateUninitializedVector return the buffer.
Previously, obtaining the buffer was unclear and required multiple casts. Change-Id: I18e01c9e669886ac250e83aad10623cbddd629b6 Tested: on Linux.
This commit is contained in:
@@ -70,6 +70,12 @@ std::string CreateFlatBufferTest() {
|
||||
unsigned char inv_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
auto inventory = builder.CreateVector(inv_data, 10);
|
||||
|
||||
// Alternatively, create the vector first, and fill in data later:
|
||||
// unsigned char *inv_buf = nullptr;
|
||||
// auto inventory = builder.CreateUninitializedVector<unsigned char>(
|
||||
// 10, &inv_buf);
|
||||
// memcpy(inv_buf, inv_data, 10);
|
||||
|
||||
Test tests[] = { Test(10, 20), Test(30, 40) };
|
||||
auto testv = builder.CreateVectorOfStructs(tests, 2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user