[PATCH 15/15] api-ms-win-core-winrt-string: Implement a few HSTRING functions.

Sebastian Lackner sebastian at fds-team.de
Sat Dec 6 10:54:49 CST 2014


On 06.12.2014 17:48, Martin Storsjö wrote:
> On Sat, 6 Dec 2014, Sebastian Lackner wrote:
> 
>> Hi Martin,
>> 
>> please note that besides functions like WindowsSubstring which
>> implicitly manipulate the string buffer, there are also some
>> functions for explicit string buffer management:
>> 
>> WindowsPreallocateStringBuffer - allocate a new string buffer with
>> refcount 1 WindowsPromoteStringBuffer - create a new string based
>> on an existing string buffer without incrementing refcount 
>> WindowsDeleteStringBuffer - decrement the refcount of a string
>> buffer
> 
> Yep, I saw these as well. Although the MSDN page for
> WindowsDeleteStringBuffer doesn't talk about refcounts anywhere I can
> see.
> 
> Is the only way of using these string buffers to allocate a certain
> size, modify the WCHAR* that WindowsPreallocateStringBuffer returned,
> or are there any other functions involved with these as well?
> 
> // Martin

No, there are no further functions involved. The idea behind this is that all WindowsStrings are immutable, and cannot (= should not) be modified anymore after a HSTRING was assigned. Allocating first the string buffer, and later promoting to a HSTRING allows to savely modify the contents (for example reading it from a file). I guess this is mainly for performance reasons, otherwise the content would always have to be copied.



More information about the wine-devel mailing list