On Mon Sep 29 14:10:59 2025 +0000, Vibhav Pant wrote:
We could, but I don't know if it would be helpful (for `canonical_name` as well).[`IPropertyValueStatics::CreateString` calls `WindowsDuplicateString`](), so the fast-pass string would anyway get copied to the heap. OTOH, `WindowsCreateStringReference` is infallible, and the `WindowsDeleteString` call wouldn't be required (though we'll need to add a `HSTRING_HEADER` declaration):
case DEVPROP_TYPE_STRING: { HSTRING_HEADER hdr; WindowsCreateStringReference( prop->Buffer, wcslen( prop->Buffer ), &str, &hdr ); hr = IPropertyValueStatics_CreateString( propval_statics, str, &val ); }
Yeah it seems better to me, especially for this case (not sure about canonical_name, it mostly depends on whether we can get rid of the property name fallback). You can even reuse the `hdr` variable.
And as you say `WindowsCreateStringReference` cannot fail, it's unnecessary to check for its results in other locations above.