Christian Costa <titan.costa(a)gmail.com> writes:
> +HRESULT WINAPI DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID* ret_iface)
> +{
> + IDirectMusicBufferImpl* dmbuffer;
> +
> + TRACE("(%p, %p)\n", desc, ret_iface);
> +
> + dmbuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicBufferImpl));
> + if (!dmbuffer) {
> + *ret_iface = NULL;
> + return E_OUTOFMEMORY;
> + }
> +
> + dmbuffer->lpVtbl = &DirectMusicBuffer_Vtbl;
> + dmbuffer->ref = 0; /* Will be inited by QueryInterface */
> +
> + memcpy(&dmbuffer->format, &desc->guidBufferFormat, sizeof(GUID));
> + dmbuffer->size = (desc->cbBuffer + 3) & ~3; /* Buffer size must be multiple of 4 bytes */
> +
> + dmbuffer->data = HeapAlloc(GetProcessHeap(), 0, sizeof(dmbuffer->size));
> + if (!dmbuffer->data) {
> + HeapFree(GetProcessHeap(), 0, dmbuffer);
> + *ret_iface = NULL;
> + return E_OUTOFMEMORY;
> + }
> +
> + return IDirectMusicBufferImpl_QueryInterface((LPDIRECTMUSICBUFFER)dmbuffer, &IID_IDirectMusicBuffer, ret_iface);
While you are changing the function please also make it handle errors
properly.
--
Alexandre Julliard
julliard(a)winehq.org