mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-26 13:01:27 +03:00
Auto merge of #155813 - JonathanBrouwer:rollup-M9eCmdI, r=JonathanBrouwer
Rollup of 2 pull requests Successful merges: - rust-lang/rust#155774 (std: maintain `CStringArray` null-termination even if `Vec::push` panics) - rust-lang/rust#155810 (Expand the initialism UCRT in rustc book)
This commit is contained in:
@@ -35,10 +35,12 @@ pub fn write(&mut self, index: usize, item: CString) {
|
|||||||
/// Push an additional string to the array.
|
/// Push an additional string to the array.
|
||||||
pub fn push(&mut self, item: CString) {
|
pub fn push(&mut self, item: CString) {
|
||||||
let argc = self.ptrs.len() - 1;
|
let argc = self.ptrs.len() - 1;
|
||||||
// Replace the null pointer at the end of the array...
|
// Amend the array by another null pointer first, to ensure that the
|
||||||
self.ptrs[argc] = item.into_raw();
|
// array is null-terminated even when the `push` panics, in which case
|
||||||
// ... and recreate it to restore the data structure invariant.
|
// the array will be left undisturbed (see #155748).
|
||||||
self.ptrs.push(ptr::null());
|
self.ptrs.push(ptr::null());
|
||||||
|
// Now, replace the previous null pointer.
|
||||||
|
self.ptrs[argc] = item.into_raw();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a pointer to the C-string array managed by this type.
|
/// Returns a pointer to the C-string array managed by this type.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
**Tier: 2 (with host tools)**
|
**Tier: 2 (with host tools)**
|
||||||
|
|
||||||
Windows targets similar to `*-windows-gnu` but using UCRT as the runtime and various LLVM tools/libraries instead of
|
Windows targets similar to `*-windows-gnu` but using Universal C Runtime (UCRT) as the runtime and various LLVM tools/libraries instead of
|
||||||
GCC/Binutils.
|
GCC/Binutils.
|
||||||
|
|
||||||
Target triples available so far:
|
Target triples available so far:
|
||||||
|
|||||||
Reference in New Issue
Block a user