-
Notifications
You must be signed in to change notification settings - Fork 764
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Standardize on Init vs InitForOverwrite for value vs default initiali…
…zation C++ is fun and has two notions of "default" initialization, `new T` and `new T()`. These are default initialization and value initialization, respectively. They are identical except that POD types are uninit when default-initialized and zero when value-initialized. InplaceVector picked the safer option by default and called the other one FooMaybeUninit. Array is older and uses the less safe one (it's almost always the one we want; we usually allocate an array to immediately fill it). While MaybeUninit does capture what you do with it, it is slightly ambiguous, as seen in Array's internal implementation: uninitialized could also mean we haven't gotten around to initialize it at all. I.e. we need to use a function like std::uninitialized_value_construct_n instead of normal functions in <algorithm>. C++20 has std::make_unique and std::make_unique_for_overwrite to capture the two. This seems as fine a naming convention as any, so switch to it. Along the way, make the internal bssl::Array default to the safer one. This lets us remove a couple of memset(0)'s. Change-Id: I32cede231da051a854e6251e10b87f8e4dd06ee6 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/72268 Reviewed-by: Nick Harper <[email protected]> Commit-Queue: David Benjamin <[email protected]>
- Loading branch information
Showing
16 changed files
with
74 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.