void RSManager::releaseResources() { SDLOG(0, "RenderstateManager release: going into neutral state\n"); for(int i = 0; i < 16; ++i) d3ddev->SetTexture(i, NULL); IDirect3DSurface9 *bb = NULL; d3ddev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &bb); d3ddev->SetRenderTarget(0, bb); SAFERELEASE(bb); SDLOG(0, "RenderstateManager releasing resources\n"); SAFEDELETE(plugin); SAFEDELETE(scaler); SAFEDELETE(perfMonitor); SAFERELEASE(depthStencilSurf); extraBuffer.reset(NULL); SAFERELEASE(prevStateBlock); SAFERELEASE(prevVDecl); SAFERELEASE(prevDepthStencilSurf); SAFERELEASE(prevRenderTarget); if(backBuffers && backBufferTextures) { for(unsigned i = 0; i < numBackBuffers; ++i) { SAFERELEASE(backBufferTextures[i]); SAFERELEASE(backBuffers[i]); } } SAFEDELETEARR(backBuffers); SAFEDELETEARR(backBufferTextures); console.cleanup(); SDLOG(0, "RenderstateManager resource release completed\n"); }
static lua_State* luacom_DoRegistryFile(const char* luaclsid) { lua_State* L_inproc = NULL; char* fileName; char* key = new char[strlen(luaclsid)+18]; strcpy(key, "CLSID\\"); strcat(key,luaclsid); strcat(key,"\\ScriptFile"); if(tCOMUtil::GetRegKeyValue(key,&fileName)) { L_inproc = luaL_newstate(); luaL_openlibs(L_inproc); #ifdef IUP /* iuplua initialization */ iuplua_open(L_inproc); iupkey_open(L_inproc); cdlua5_open(L_inproc); #ifndef NO_CPICONTROLS controlslua_open(L_inproc); gllua_open(L_inproc); #endif #ifdef SPEECH_SDK speechlua_open(L_inproc); #endif #ifdef USE_GLLUA gl_open(L_inproc); #endif iupluaim_open(L_inproc); #endif luacom_open(L_inproc); lua_pushvalue(L_inproc, LUA_REGISTRYINDEX); lua_pushstring(L_inproc,"inproc"); lua_pushboolean(L_inproc,TRUE); lua_settable(L_inproc,-3); lua_pop(L_inproc,1); if(!lua_dofile(L_inproc,fileName)) { lua_pushstring(L_inproc,"StartAutomation"); lua_gettable(L_inproc,-2); if(luaCompat_call(L_inproc, 0, 0)) { luacom_close(L_inproc); lua_close(L_inproc); L_inproc = NULL; } } else { luacom_close(L_inproc); lua_close(L_inproc); L_inproc = NULL; } } delete[] key; SAFEDELETEARR(fileName); return L_inproc; }
// // Delete dynamic memory // CSerialPort::~CSerialPort() { if (m_hThreadComm != INVALID_HANDLE_VALUE) { SetEvent(m_hShutdownEvent); WaitForSingleObject(m_hThreadComm, INFINITE); WaitForSingleObject(m_hThreadSend, INFINITE); CLOSEHANDLE(m_hThreadComm); CLOSEHANDLE(m_hThreadSend); } CLOSEHANDLE(m_hEventSent); CLOSEHANDLE(m_hShutdownEvent); CLOSEHANDLE(m_hComm); CLOSEHANDLE(m_hWriteEvent); CLOSEHANDLE(m_ov.hEvent); DeleteCriticalSection(&m_csCommunicationSync); //JLOG(_T("CSerialPort::Thread ended\n")); SAFEDELETEARR(m_dataWriteBuffer); }