diff --git a/dlls/winegstreamer/wg_sample.c b/dlls/winegstreamer/wg_sample.c index ae8a2d4d0c7..eb46982fabf 100644 --- a/dlls/winegstreamer/wg_sample.c +++ b/dlls/winegstreamer/wg_sample.c @@ -47,6 +47,11 @@ struct sample
union {
struct
{
void *__pad[3];
BYTE buffer[];
} raw; struct { IMFSample *sample;
Why the padding?
So that buffer is aligned to the end of the structure and so that we can safely use a flexible array member. Otherwise offsetof buffer[size] may be shorter than the struct, ending up with a undefined behavior when accessing a partially allocated structure and an eventual GCC warning.
+HRESULT wg_sample_create_raw(UINT32 size, struct wg_sample **out) +{
- struct sample *sample;
- if (!(sample = calloc(1, offsetof(struct sample, u.raw.buffer[size]))))
return E_OUTOFMEMORY;
- sample->wg_sample.data = sample->u.raw.buffer;
- sample->wg_sample.size = 0;
- sample->wg_sample.max_size = size;
- sample->ops = &raw_sample_ops;
- TRACE("Created wg_sample %p, size %u.\n", &sample->wg_sample, size);
- *out = &sample->wg_sample;
- return S_OK;
+}
It strikes me as unnecessary to return HRESULT from this function, especially considering you're not actually using the HRESULT value (only testing for failure). It'd be simpler just to return "sample" in that case.
It makes it consistent with the other sample creation functions, and other creations functions in general.