[3/3] d3dx9: Begin Implementation of ID3DXEffect and D3DXCreateEffectEx

tony.wasserka at freenet.de tony.wasserka at freenet.de
Mon Aug 25 13:29:13 CDT 2008


Hi,
> +HRESULT WINAPI D3DXCreateEffectEx(LPDIRECT3DDEVICE9 pdevice, LPCVOID
psrcdata, UINT srcdatalen, D3DXMACRO *pdefines,
> +  LPD3DXINCLUDE pinclude,  LPCSTR pskipconstants,  DWORD flags, 
LPD3DXEFFECTPOOL ppool,  LPD3DXEFFECT * ppeffect,
> +  LPD3DXBUFFER * ppcompilationerrors)
> +{
> +    ID3DXEffectImpl *This;
> +    This=(ID3DXEffectImpl *)malloc(sizeof(ID3DXEffectImpl));
> +    This->lpVtbl=&ID3DXEffect_Vtbl;
> +    This->device=pdevice;
> +    return D3D_OK;
> +}
> +
Don't use malloc for windows functions, use HeapAlloc for that.
Also, you should do some error checking to make sure that the memory was
allocated successfully, or this code will segfault.
You forgot to assign the ppeffect pointer to This, i.e. *ppeffect=This.
you'll need to check that ppeffect isn't NULL first, of course.
At least ID3DXBaseEffectImpl_AddRef/Release/QueryInterface (well,
actually only Release) need to be implemented in the same patch as the
interface leaks memory otherwise (one more unnecessary valgrind error).
Last thing, you need to AddRef the device when creating another
reference to it, and Release it on ID3DXBaseEffectImpl_Release. (Though
a device pointer isn't even neccessary yet, so you could also leave it
away)

Best regards,
 Tony




Heute schon ge"freeMail"t?
Jetzt kostenlose E-Mail-Adresse
sichern!
http://email.freenet.de/dienste/emailoffice/produktuebersicht/basic/mail/index.html?pid=6831




More information about the wine-devel mailing list