Rémi Bernon (@rbernon) commented about dlls/dmsynth/synth.c:
if (wave_info->WaveformatEx.wFormatTag != WAVE_FORMAT_PCM) return DMUS_E_NOTPCM;
sample_count = wave_data->cbSize / wave_info->WaveformatEx.nBlockAlign; - if (!(wave = calloc(1, offsetof(struct wave, samples[sample_count])))) return E_OUTOFMEMORY; + if (!(wave = calloc(1, sizeof(struct wave)))) return E_OUTOFMEMORY;
You could keep the single allocation, while still using a pointer for the samples (with 0 extra allocation size if the samples don't need to be copied). It would save some error handling and you could only replace the `wave_info->WaveformatEx.nBlockAlign == 2` conditional block below, without having to split it in two (which makes it slightly less obvious that the sample conversion is exclusive with the zero-copy). -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9373#note_121072