Round vector_downward initial size up (#4179)
diff --git a/include/flatbuffers/flatbuffers.h b/include/flatbuffers/flatbuffers.h
index 83b4fa1..47e3757 100644
--- a/include/flatbuffers/flatbuffers.h
+++ b/include/flatbuffers/flatbuffers.h
@@ -496,12 +496,11 @@
public:
explicit vector_downward(size_t initial_size,
const simple_allocator &allocator)
- : reserved_(initial_size),
+ : reserved_((initial_size + sizeof(largest_scalar_t) - 1) &
+ ~(sizeof(largest_scalar_t) - 1)),
buf_(allocator.allocate(reserved_)),
cur_(buf_ + reserved_),
- allocator_(allocator) {
- assert((initial_size & (sizeof(largest_scalar_t) - 1)) == 0);
- }
+ allocator_(allocator) {}
~vector_downward() {
if (buf_)