cleanup Create_DirectDraw after all debuging and thx w3seek thuse advice. I was getting insaine why malloc fail.

svn path=/trunk/; revision=27048
This commit is contained in:
Magnus Olsen 2007-06-07 13:02:10 +00:00
parent bfccdbeac1
commit a4e1dbf9bd

View file

@ -12,7 +12,6 @@
#include "ddrawgdi.h" #include "ddrawgdi.h"
DDRAWI_DIRECTDRAW_GBL ddgbl; DDRAWI_DIRECTDRAW_GBL ddgbl;
DDRAWI_DIRECTDRAW_INT primaryDirectDrawInt;
DDRAWI_DDRAWSURFACE_GBL ddSurfGbl; DDRAWI_DDRAWSURFACE_GBL ddSurfGbl;
WCHAR classname[128]; WCHAR classname[128];
@ -33,46 +32,31 @@ Create_DirectDraw (LPGUID pGUID, LPDIRECTDRAW* pIface,
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
} }
DX_STUB_str("here\n");
This = (LPDDRAWI_DIRECTDRAW_INT)*pIface; This = (LPDDRAWI_DIRECTDRAW_INT)*pIface;
/* fixme linking too second link when we shall not doing it */ /* fixme linking too second link when we shall not doing it */
if (IsBadReadPtr(This,sizeof(LPDIRECTDRAW))) if (IsBadReadPtr(This,sizeof(LPDIRECTDRAW)))
{ {
DX_STUB_str("1. no linking\n"); DX_STUB_str("1. no linking\n");
/* We do not have a DirectDraw interface, we need alloc it*/ /* We do not have a DirectDraw interface, we need alloc it*/
LPDDRAWI_DIRECTDRAW_INT memThis; LPDDRAWI_DIRECTDRAW_INT memThis;
DX_STUB_str("here\n"); DxHeapMemAlloc(memThis, sizeof(DDRAWI_DIRECTDRAW_INT));
memThis = &primaryDirectDrawInt;
RtlZeroMemory(memThis, sizeof(DDRAWI_DIRECTDRAW_INT));
DX_STUB_str("here\n")
if (memThis == NULL) if (memThis == NULL)
{ {
DX_STUB_str("DDERR_OUTOFMEMORY\n");
return DDERR_OUTOFMEMORY; return DDERR_OUTOFMEMORY;
} }
This = memThis; This = memThis;
DX_STUB_str("here\n");
/* Fixme release memory alloc if we fail */ /* Fixme release memory alloc if we fail */
DxHeapMemAlloc(This->lpLcl, sizeof(DDRAWI_DIRECTDRAW_LCL)); DxHeapMemAlloc(This->lpLcl, sizeof(DDRAWI_DIRECTDRAW_LCL));
if (This->lpLcl == NULL) if (This->lpLcl == NULL)
{ {
DX_STUB_str("DDERR_OUTOFMEMORY\n");
return DDERR_OUTOFMEMORY; return DDERR_OUTOFMEMORY;
} }
DX_STUB_str("here\n");
} }
else else
{ {
@ -80,31 +64,23 @@ Create_DirectDraw (LPGUID pGUID, LPDIRECTDRAW* pIface,
/* We got the DirectDraw interface alloc and we need create the link */ /* We got the DirectDraw interface alloc and we need create the link */
LPDDRAWI_DIRECTDRAW_INT newThis; LPDDRAWI_DIRECTDRAW_INT newThis;
DX_STUB_str("here\n");
/* step 1.Alloc the new DDRAWI_DIRECTDRAW_INT for the lnking */ /* step 1.Alloc the new DDRAWI_DIRECTDRAW_INT for the lnking */
DxHeapMemAlloc(newThis, sizeof(DDRAWI_DIRECTDRAW_INT)); DxHeapMemAlloc(newThis, sizeof(DDRAWI_DIRECTDRAW_INT));
if (newThis == NULL) if (newThis == NULL)
{ {
DX_STUB_str("DDERR_OUTOFMEMORY\n");
return DDERR_OUTOFMEMORY; return DDERR_OUTOFMEMORY;
} }
DX_STUB_str("here\n");
/* step 2 check if it not DDCREATE_HARDWAREONLY we got if so we fail */ /* step 2 check if it not DDCREATE_HARDWAREONLY we got if so we fail */
if ((pGUID) && (pGUID != (LPGUID)DDCREATE_HARDWAREONLY)) if ((pGUID) && (pGUID != (LPGUID)DDCREATE_HARDWAREONLY))
{ {
if (pGUID !=NULL) if (pGUID !=NULL)
{ {
This = newThis; This = newThis;
DX_STUB_str("DDERR_INVALIDDIRECTDRAWGUID\n");
return DDERR_INVALIDDIRECTDRAWGUID; return DDERR_INVALIDDIRECTDRAWGUID;
} }
} }
DX_STUB_str("here\n");
/* step 3 do the link the old interface are store in the new one */ /* step 3 do the link the old interface are store in the new one */
newThis->lpLink = This; newThis->lpLink = This;
@ -113,16 +89,12 @@ Create_DirectDraw (LPGUID pGUID, LPDIRECTDRAW* pIface,
if (newThis->lpLcl == NULL) if (newThis->lpLcl == NULL)
{ {
This = newThis; This = newThis;
DX_STUB_str("DDERR_OUTOFMEMORY\n");
return DDERR_OUTOFMEMORY; return DDERR_OUTOFMEMORY;
} }
DX_STUB_str("here\n");
This = newThis; This = newThis;
} }
This->lpLcl->lpGbl = &ddgbl; This->lpLcl->lpGbl = &ddgbl;
*pIface = (LPDIRECTDRAW)This; *pIface = (LPDIRECTDRAW)This;
@ -152,13 +124,10 @@ Create_DirectDraw (LPGUID pGUID, LPDIRECTDRAW* pIface,
return DDERR_GENERIC; return DDERR_GENERIC;
} }
*/ */
DX_STUB_str("DD_OK\n");
return DD_OK; return DD_OK;
} }
} }
DX_STUB_str("DDERR_INVALIDPARAMS\n");
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
} }