Author: greatlrd
Date: Sat Jun 23 13:57:34 2007
New Revision: 27266
URL:
http://svn.reactos.org/svn/reactos?rev=27266&view=rev
Log:
simplefly Main_DirectDraw_QueryInterface code
Modified:
trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c
Modified: trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/Ddraw/dd…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c (original)
+++ trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c Sat Jun 23 13:57:34 2007
@@ -14,12 +14,30 @@
* table to right version of the functions
*/
+
+
#include "rosdraw.h"
#include <string.h>
/* PSEH for SEH Support */
#include <pseh/pseh.h>
+
+
+
+LPDDRAWI_DIRECTDRAW_INT
+internal_directdraw_int_alloc(LPDDRAWI_DIRECTDRAW_INT This)
+{
+ LPDDRAWI_DIRECTDRAW_INT newThis;
+ DxHeapMemAlloc(newThis, sizeof(DDRAWI_DIRECTDRAW_INT));
+ if (newThis)
+ {
+ newThis->lpLcl = This->lpLcl;
+ newThis->lpLink = This;
+ }
+
+ return newThis;
+}
HRESULT WINAPI
Main_DirectDraw_QueryInterface (LPDDRAWI_DIRECTDRAW_INT This,
@@ -40,109 +58,66 @@
{
if (This->lpVtbl != &DirectDraw7_Vtable)
{
- LPDDRAWI_DIRECTDRAW_INT newThis;
- DxHeapMemAlloc(newThis, sizeof(DDRAWI_DIRECTDRAW_INT));
-
- if (newThis == NULL)
- {
- retVal = DDERR_OUTOFMEMORY;
- }
- else
- {
- /* DirectDraw7 Vtable */
- newThis->lpVtbl = &DirectDraw7_Vtable;
- newThis->lpLcl = This->lpLcl;
- newThis->lpLink = This;
- *obj = &newThis->lpVtbl;
- Main_DirectDraw_AddRef(newThis);
- }
- }
- else
- {
- *obj = This;
- Main_DirectDraw_AddRef(This);
- }
+ This = internal_directdraw_int_alloc(This);
+ if (!This)
+ {
+ retVal = DDERR_OUTOFVIDEOMEMORY;
+ _SEH_LEAVE;
+ }
+ }
+
+ This->lpVtbl = &DirectDraw7_Vtable;
+ *obj = This;
+ Main_DirectDraw_AddRef(This);
}
else if (IsEqualGUID(&IID_IDirectDraw4, id))
{
if (This->lpVtbl != &DirectDraw4_Vtable)
{
- LPDDRAWI_DIRECTDRAW_INT newThis;
- DxHeapMemAlloc(newThis, sizeof(DDRAWI_DIRECTDRAW_INT));
-
- if (newThis == NULL)
- {
- retVal = DDERR_OUTOFMEMORY;
- }
- else
- {
- /* DirectDraw4 Vtable */
- newThis->lpVtbl = &DirectDraw4_Vtable;
- newThis->lpLcl = This->lpLcl;
- newThis->lpLink = This;
- *obj = &newThis->lpVtbl;
- Main_DirectDraw_AddRef(newThis);
- }
- }
- else
- {
- *obj = This;
- Main_DirectDraw_AddRef(This);
- }
- }
- else if (IsEqualGUID(&IID_IDirectDraw2, id))
- {
- if (This->lpVtbl != &DirectDraw2_Vtable)
- {
- LPDDRAWI_DIRECTDRAW_INT newThis;
- DxHeapMemAlloc(newThis, sizeof(DDRAWI_DIRECTDRAW_INT));
-
- if (newThis == NULL)
- {
- retVal = DDERR_OUTOFMEMORY;
- }
- else
- {
- /* DirectDraw4 Vtable */
- newThis->lpVtbl = &DirectDraw2_Vtable;
- newThis->lpLcl = This->lpLcl;
- newThis->lpLink = This;
- *obj = &newThis->lpVtbl;
- Main_DirectDraw_AddRef(newThis);
- }
- }
- else
- {
- *obj = This;
- Main_DirectDraw_AddRef(This);
- }
+ This = internal_directdraw_int_alloc(This);
+ if (!This)
+ {
+ retVal = DDERR_OUTOFVIDEOMEMORY;
+ _SEH_LEAVE;
+ }
+ }
+
+ This->lpVtbl = &DirectDraw2_Vtable;
+ *obj = This;
+ Main_DirectDraw_AddRef(This);
+ }
+
+ else if (IsEqualGUID(&IID_IDirectDraw4, id))
+ {
+ if (This->lpVtbl != &DirectDraw4_Vtable)
+ {
+ This = internal_directdraw_int_alloc(This);
+ if (!This)
+ {
+ retVal = DDERR_OUTOFVIDEOMEMORY;
+ _SEH_LEAVE;
+ }
+ }
+
+ This->lpVtbl = &DirectDraw2_Vtable;
+ *obj = This;
+ Main_DirectDraw_AddRef(This);
}
else if (IsEqualGUID(&IID_IDirectDraw, id))
{
if (This->lpVtbl != &DirectDraw_Vtable)
{
- LPDDRAWI_DIRECTDRAW_INT newThis;
- DxHeapMemAlloc(newThis, sizeof(DDRAWI_DIRECTDRAW_INT));
-
- if (newThis == NULL)
- {
- retVal = DDERR_OUTOFMEMORY;
- }
- else
- {
- /* DirectDraw Vtable */
- newThis->lpVtbl = &DirectDraw_Vtable;
- newThis->lpLcl = This->lpLcl;
- newThis->lpLink = This;
- *obj = &newThis->lpVtbl;
- Main_DirectDraw_AddRef(newThis);
- }
- }
- else
- {
- *obj = This;
- Main_DirectDraw_AddRef(This);
- }
+ This = internal_directdraw_int_alloc(This);
+ if (!This)
+ {
+ retVal = DDERR_OUTOFVIDEOMEMORY;
+ _SEH_LEAVE;
+ }
+ }
+
+ This->lpVtbl = &DirectDraw_Vtable;
+ *obj = This;
+ Main_DirectDraw_AddRef(This);
}
else
{