Repository navigation
Add HSTRING builder and registry support - #3133
Merged
Merged
Conversation
Collaborator
Author
|
Thanks to Rafael Rivera (@riverar) for helping me fix that natvis... again. 😂 |
Kenny Kerr (kennykerr)
requested review from
Chris Denton (ChrisDenton) and
Rafael Rivera (riverar)
June 27, 2024 19:27
Rafael Rivera (riverar)
approved these changes
Jun 27, 2024
Chris Denton (ChrisDenton)
approved these changes
Jun 28, 2024
Merged
|
|
||
| fn deref(&self) -> &[u16] { | ||
| if let Some(header) = self.as_header() { | ||
| unsafe { core::slice::from_raw_parts(header.data, header.len as usize) } |
Contributor
There was a problem hiding this comment.
Doesn't this expose uninitialized memory? i.e. *HStringBuilder::new(123).unwrap() is a [u16] slice whose contents are uninitialized.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This update adds two features to improve string support and efficiency.
The
HSTRINGtype now includes anHStringBuildertype for pre-allocating and constructing anHSTRINGwithout requiring an additional copy. This is similar to theWindowsPreallocateStringBufferfunction but implemented directly in Rust, as I did for C++/WinRT back in the day.The
windows-registrycrate now also provideget_hstringandset_hstringfor reading and writing registry values usingHSTRING. This is far more efficient than eitherStringorOsStringand is lossless, while still providing convertibility withStringandOsString.Fixes: #3119