[PATCH v5 5/5] combase: Reorder hstring_private elements.
Bernhard Kölbl
besentv at gmail.com
Mon Jan 24 06:22:32 CST 2022
Whoopsie.. Yeah, my bad. :)
I'll send in a v6 shortly.
Bernhard
Am Mo., 24. Jan. 2022 um 11:47 Uhr schrieb Huw Davies <huw at codeweavers.com>:
>
> On Thu, Jan 13, 2022 at 12:34:18AM +0100, Bernhard Kölbl wrote:
> > Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51017
> >
> > Put the string buffer at the end of the struct to
> > match the Windows behaviour and avoid unnecessary
> > pointer arithmetic.
> >
> > Signed-off-by: Bernhard Kölbl <besentv at gmail.com>
> > ---
> > v5: Split the patch into multiple commits and minor code changes.
> > v4: Remove leftover debugging TRACE and minor style changes.
> > v3: Add nested hstring_header struct to hstring_private and add a test for both.
> > v2: I was mistaken about no reference counting being used.
> > ---
> > dlls/combase/string.c | 8 ++++----
> > dlls/combase/tests/string.c | 8 --------
> > 2 files changed, 4 insertions(+), 12 deletions(-)
> >
> > diff --git a/dlls/combase/string.c b/dlls/combase/string.c
> > index 24d1e4dd8f9..fa35262fbf9 100644
> > --- a/dlls/combase/string.c
> > +++ b/dlls/combase/string.c
> > @@ -40,8 +40,8 @@ struct hstring_header
> > struct hstring_private
> > {
> > struct hstring_header header;
> > - LPWSTR buffer;
> > - LONG refcount;
> > + LONG refcount;
> > + WCHAR buffer[1];
> > }
> >
> > static const WCHAR empty[1];
> > @@ -66,14 +66,14 @@ static inline struct hstring_private *impl_from_HSTRING_BUFFER(HSTRING_BUFFER bu
> > static BOOL alloc_string(UINT32 len, HSTRING *out)
> > {
> > struct hstring_private *priv;
> > - priv = HeapAlloc(GetProcessHeap(), 0, sizeof(*priv) + (len + 1) * sizeof(*priv->buffer));
> > + priv = HeapAlloc(GetProcessHeap(), 0, offsetof(struct hstring_private, buffer[len]));
>
> Should be [len + 1] (my fault, but you should have spotted it ;-)
>
> Huw.
More information about the wine-devel
mailing list