ULONG WINAPI IDirect3DDevice9Base_Release(LPDIRECT3DDEVICE9 iface) { LPDIRECT3DDEVICE9_INT This = IDirect3DDevice9ToImpl(iface); ULONG ref = InterlockedDecrement(&This->lRefCnt); if (ref == 0) { DWORD iAdapter; EnterCriticalSection(&This->CriticalSection); /* TODO: Free resources here */ for (iAdapter = 0; iAdapter < This->NumAdaptersInDevice; iAdapter++) { DestroyD3D9DeviceData(&This->DeviceData[iAdapter]); } This->lpVtbl->VirtualDestructor(iface); LeaveCriticalSection(&This->CriticalSection); AlignedFree(This); } return ref; }
static BOOL GetDirect3D9AdapterInfo(IN OUT LPDIRECT3D9_DISPLAYADAPTER pDisplayAdapters, IN DWORD AdapterIndex) { LPD3D9_DEVICEDATA pDeviceData; pDeviceData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(D3D9_DEVICEDATA)); if (NULL == pDeviceData) { DPRINT1("Out of memory, could not initialize Direct3D adapter"); return FALSE; } if (FALSE == CreateD3D9DeviceData(&pDisplayAdapters[AdapterIndex], pDeviceData)) { DPRINT1("Could not create device data for adapter: %d", AdapterIndex); return FALSE; } GetDisplayAdapterFromDevice(pDisplayAdapters, AdapterIndex, pDeviceData); DestroyD3D9DeviceData(pDeviceData); HeapFree(GetProcessHeap(), 0, pDeviceData); return TRUE; }