rnpgp / rnp

RNP: high performance C++ OpenPGP library used by Mozilla Thunderbird
https://www.rnpgp.org
Other
191 stars 54 forks source link

Explicitly initialize POD struct fields. #1123

Open ni4 opened 4 years ago

ni4 commented 4 years ago

Description

As from discussion at https://github.com/rnpgp/rnp/pull/1109#issuecomment-624612517 we should {} - initialize all struct fields to avoid possible further initialization errors.

antonsviridenko commented 4 years ago

maybe just memset(&s, 0, sizeof some_struct_t); ?

dewyatt commented 4 years ago

maybe just memset(&s, 0, sizeof some_struct_t); ?

It's not very C++-y, it relies on all members remaining POD, and it seems maybe more likely to be a runtime vs compile-time thing.

ni4 commented 4 years ago

maybe just memset(&s, 0, sizeof some_struct_t); ?

That will not work within the migration to C++, when, for instance, list variables will become a std::vector or std::map.

rrrooommmaaa commented 3 years ago

So, I'm going to replace calloc with new and free with delete, right?

rrrooommmaaa commented 3 years ago

for all these:

ni4 commented 3 years ago

Please not yet, if possible - I have some postponed code which will definitely conflict with those changes (see https://github.com/ni4/rnp/pull/4)