mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-27 02:02:18 +00:00
[C++] Got rid of memset's in constructors (#5938)
* [C++] removed array's memsets from struct parametrized constructor now POD-typed arrays are zero-initialized and class-typed arrays are default-initialized * [C++] memset -> zero/default initialization in default constructor * [C++] Struct-type and array default initialization * [C++] Newly generated tests * [C++] forgotten test * [C++] curly brace by code style * [C++] test if memory is 0's after placement new * [C++] memory leak fix * [C++] simplifying and non-dynamic memory in test * [C++] code cleanup * [C++] disable old-compiler warning * [C++] windows build fix (try) * [C++] debug-new win build fix
This commit is contained in:
@@ -75,15 +75,23 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) NestedStruct FLATBUFFERS_FINAL_CLASS {
|
||||
static const flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return NestedStructTypeTable();
|
||||
}
|
||||
NestedStruct() {
|
||||
memset(static_cast<void *>(this), 0, sizeof(NestedStruct));
|
||||
NestedStruct()
|
||||
: a_(),
|
||||
b_(0),
|
||||
c_(),
|
||||
padding0__(0),
|
||||
padding1__(0),
|
||||
d_() {
|
||||
(void)padding0__;
|
||||
(void)padding1__;
|
||||
}
|
||||
NestedStruct(MyGame::Example::TestEnum _b)
|
||||
: b_(flatbuffers::EndianScalar(static_cast<int8_t>(_b))) {
|
||||
std::memset(a_, 0, sizeof(a_));
|
||||
std::memset(c_, 0, sizeof(c_));
|
||||
(void)padding0__; (void)padding1__;
|
||||
std::memset(d_, 0, sizeof(d_));
|
||||
: a_(),
|
||||
b_(flatbuffers::EndianScalar(static_cast<int8_t>(_b))),
|
||||
c_(),
|
||||
padding0__(0),
|
||||
padding1__(0),
|
||||
d_() {
|
||||
}
|
||||
const flatbuffers::Array<int32_t, 2> *a() const {
|
||||
return reinterpret_cast<const flatbuffers::Array<int32_t, 2> *>(a_);
|
||||
@@ -140,22 +148,33 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) ArrayStruct FLATBUFFERS_FINAL_CLASS {
|
||||
static const flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||
return ArrayStructTypeTable();
|
||||
}
|
||||
ArrayStruct() {
|
||||
memset(static_cast<void *>(this), 0, sizeof(ArrayStruct));
|
||||
ArrayStruct()
|
||||
: a_(0),
|
||||
b_(),
|
||||
c_(0),
|
||||
padding0__(0),
|
||||
padding1__(0),
|
||||
padding2__(0),
|
||||
d_(),
|
||||
e_(0),
|
||||
padding3__(0),
|
||||
f_() {
|
||||
(void)padding0__;
|
||||
(void)padding1__;
|
||||
(void)padding2__;
|
||||
(void)padding3__;
|
||||
}
|
||||
ArrayStruct(float _a, int8_t _c, int32_t _e)
|
||||
: a_(flatbuffers::EndianScalar(_a)),
|
||||
b_(),
|
||||
c_(flatbuffers::EndianScalar(_c)),
|
||||
padding0__(0),
|
||||
padding1__(0),
|
||||
padding2__(0),
|
||||
d_(),
|
||||
e_(flatbuffers::EndianScalar(_e)),
|
||||
padding3__(0) {
|
||||
std::memset(b_, 0, sizeof(b_));
|
||||
(void)padding0__; (void)padding1__; (void)padding2__;
|
||||
std::memset(d_, 0, sizeof(d_));
|
||||
(void)padding3__;
|
||||
std::memset(f_, 0, sizeof(f_));
|
||||
padding3__(0),
|
||||
f_() {
|
||||
}
|
||||
float a() const {
|
||||
return flatbuffers::EndianScalar(a_);
|
||||
|
||||
Reference in New Issue
Block a user