// static XPCNativeSet* XPCNativeSet::GetNewOrUsed(XPCCallContext& ccx, const nsIID* iid) { AutoMarkingNativeSetPtr set(ccx); AutoMarkingNativeInterfacePtr iface(ccx); iface = XPCNativeInterface::GetNewOrUsed(ccx, iid); if(!iface) return nsnull; XPCNativeSetKey key(nsnull, iface, 0); XPCJSRuntime* rt = ccx.GetRuntime(); NativeSetMap* map = rt->GetNativeSetMap(); if(!map) return nsnull; { // scoped lock XPCAutoLock lock(rt->GetMapLock()); set = map->Find(&key); } if(set) return set; // hacky way to get a XPCNativeInterface** using the AutoPtr XPCNativeInterface* temp[] = {iface}; set = NewInstance(ccx, temp, 1); if(!set) return nsnull; { // scoped lock XPCAutoLock lock(rt->GetMapLock()); XPCNativeSet* set2 = map->Add(&key, set); if(!set2) { NS_ERROR("failed to add our set!"); DestroyInstance(set); set = nsnull; } else if(set2 != set) { DestroyInstance(set); set = set2; } } return set; }
// static XPCNativeSet* XPCNativeSet::GetNewOrUsed(XPCCallContext& ccx, XPCNativeSet* otherSet, XPCNativeInterface* newInterface, PRUint16 position) { AutoMarkingNativeSetPtr set(ccx); XPCJSRuntime* rt = ccx.GetRuntime(); NativeSetMap* map = rt->GetNativeSetMap(); if(!map) return nsnull; XPCNativeSetKey key(otherSet, newInterface, position); { // scoped lock XPCAutoLock lock(rt->GetMapLock()); set = map->Find(&key); } if(set) return set; if(otherSet) set = NewInstanceMutate(otherSet, newInterface, position); else set = NewInstance(ccx, &newInterface, 1); if(!set) return nsnull; { // scoped lock XPCAutoLock lock(rt->GetMapLock()); XPCNativeSet* set2 = map->Add(&key, set); if(!set2) { NS_ERROR("failed to add our set!"); DestroyInstance(set); set = nsnull; } else if(set2 != set) { DestroyInstance(set); set = set2; } } return set; }
void EmptyTrash(void) { register unsigned c; register unsigned long i,len; register struct DumpRec *p,*next; register struct gl_list_t *l; if (g_dump_inst_count==0) return; for(c=0;c<DUMPHASHSIZE;c++) { p = g_dump_ht[c]; g_dump_ht[c]=NULL; while (p!=NULL) { AssertAllocatedMemory(p,sizeof(struct DumpRec)); next = p->next; if ((l=p->instances)!=NULL) { len = gl_length(l); for(i=1;i<=len;i++) DestroyInstance((struct Instance *)gl_fetch(l,i),NULL); gl_destroy(l); } ascfree((char *)p); p = next; } } g_dump_type_count = 0; g_dump_inst_count = 0; }
void MapInstanced::Update(const uint32 t) { // take care of loaded GridMaps (when unused, unload it!) Map::Update(t); // update the instanced maps InstancedMaps::iterator i = m_InstancedMaps.begin(); while (i != m_InstancedMaps.end()) { if (i->second->CanUnload(t)) { if (!DestroyInstance(i)) // iterator incremented { //m_unloadTimer } } else { // update only here, because it may schedule some bad things before delete if (sMapMgr->GetMapUpdater()->activated()) sMapMgr->GetMapUpdater()->schedule_update(*i->second, t); else i->second->Update(t); ++i; } } }
// static XPCNativeInterface* XPCNativeInterface::GetNewOrUsed(XPCCallContext& ccx, const nsIID* iid) { AutoMarkingNativeInterfacePtr iface(ccx); XPCJSRuntime* rt = ccx.GetRuntime(); IID2NativeInterfaceMap* map = rt->GetIID2NativeInterfaceMap(); if(!map) return nsnull; { // scoped lock XPCAutoLock lock(rt->GetMapLock()); iface = map->Find(*iid); } if(iface) return iface; nsCOMPtr<nsIInterfaceInfo> info; ccx.GetXPConnect()->GetInfoForIID(iid, getter_AddRefs(info)); if(!info) return nsnull; iface = NewInstance(ccx, info); if(!iface) return nsnull; { // scoped lock XPCAutoLock lock(rt->GetMapLock()); XPCNativeInterface* iface2 = map->Add(iface); if(!iface2) { NS_ERROR("failed to add our interface!"); DestroyInstance(ccx, rt, iface); iface = nsnull; } else if(iface2 != iface) { DestroyInstance(ccx, rt, iface); iface = iface2; } } return iface; }
// static XPCNativeInterface* XPCNativeInterface::GetNewOrUsed(XPCCallContext& ccx, nsIInterfaceInfo* info) { AutoMarkingNativeInterfacePtr iface(ccx); const nsIID* iid; if(NS_FAILED(info->GetIIDShared(&iid)) || !iid) return nsnull; XPCJSRuntime* rt = ccx.GetRuntime(); IID2NativeInterfaceMap* map = rt->GetIID2NativeInterfaceMap(); if(!map) return nsnull; { // scoped lock XPCAutoLock lock(rt->GetMapLock()); iface = map->Find(*iid); } if(iface) return iface; iface = NewInstance(ccx, info); if(!iface) return nsnull; { // scoped lock XPCAutoLock lock(rt->GetMapLock()); XPCNativeInterface* iface2 = map->Add(iface); if(!iface2) { NS_ERROR("failed to add our interface!"); DestroyInstance(ccx, rt, iface); iface = nsnull; } else if(iface2 != iface) { DestroyInstance(ccx, rt, iface); iface = iface2; } } return iface; }
void CEventManager::Terminate() { m_bIsInit = false; //if (m_Thread.joinable()) // m_Thread.join(); DestroyInstance(); };
/* ======== Engine::RunScene Initializes the engine, and runs the scene passed in. ======== */ int Engine::RunScene( Scene* scene ) { Engine* inst = GetInstance(); inst->SetScene(scene); int retValue = inst->MainLoop(); GetInstance()->Shutdown(); DestroyInstance(); return retValue; }
//==================================== // Creates the DInputDeviceDB object //==================================== FUSIONPLUGIN void GetInstance(Fusion &f) { fusion = &f; if(fusion->Input == NULL){ fusion->Input = new DI8InputDeviceDB(); if(fusion->Input->Initialise() == false){ DestroyInstance(); } } }
//==================================== // Creates the Network object //==================================== FUSIONPLUGIN void GetInstance(Fusion &f) { fusion = &f; if(fusion->Network == NULL){ fusion->Network = new WSANetworkCore(); if(fusion->Network->Initialise() == false){ DestroyInstance(); } } }
BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: CreateInstance(); break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: DestroyInstance(); break; } return TRUE; }
void TendTrash(void) { register unsigned c; register unsigned long i; register struct DumpRec *p; register struct gl_list_t *l; if (g_dump_inst_count <= MESSYTHRESH) return; for(c=0;c<DUMPHASHSIZE;c++) { p = g_dump_ht[c]; while(p!=NULL) { if ((l=p->instances)!=NULL) { for (i=gl_length(l);i>MESSYTHRESH;i--) { DestroyInstance((struct Instance *)gl_fetch(l,i),NULL); g_dump_inst_count--; gl_delete(l,i,0); } } p = p->next; } } }
void MapInstanced::Update(const uint32& t) { // take care of loaded GridMaps (when unused, unload it!) Map::Update(t); // update the instanced maps InstancedMaps::iterator i = m_InstancedMaps.begin(); while (i != m_InstancedMaps.end()) { if (i->second->CanUnload(t)) { DestroyInstance(i); // iterator incremented } else { // update only here, because it may schedule some bad things before delete i->second->Update(t); ++i; } } }
void TrashType(symchar *str) { register unsigned long c,len,bucket; register struct DumpRec *p,*prev; register struct gl_list_t *l; register int cmp; assert(AscFindSymbol(str)!=NULL); if (*(SCP(str)) == '\0') return; bucket = DUMPHASHINDEX(SCP(str)); if ((p = g_dump_ht[bucket])==NULL) return; cmp = CmpSymchar(p->type,str); if (cmp == 0) g_dump_ht[bucket] = p->next; else if (cmp > 0) return; else { prev = p; if ((p = p->next)==NULL) return; while((cmp=CmpSymchar(p->type,str))<0) { prev = p; if ((p=p->next)==NULL) return; } if (cmp!=0) return; /* remove from linked list */ prev->next = p->next; } if ((l=p->instances)!=NULL) { len = gl_length(l); for(c=1;c<=len;c++) DestroyInstance((struct Instance *)gl_fetch(l,c),NULL); gl_destroy(l); g_dump_inst_count -= len; } g_dump_type_count--; ascfree((char *)p); }
void MapInstanced::DestroyInstance(uint32 InstanceId) { InstancedMaps::iterator itr = m_InstancedMaps.find(InstanceId); if(itr != m_InstancedMaps.end()) DestroyInstance(itr); }
CImageDecoder::~CImageDecoder() { DestroyInstance(); }
/***************************************************************************\ * DdeUninitialize (DDEML API) * * Description: * Shuts down a DDEML instance and frees all associated resources. * * History: * 11-12-91 sanfords Created. \***************************************************************************/ BOOL DdeUninitialize( DWORD idInst) { PCL_INSTANCE_INFO pcii, pciiPrev; BOOL fRet = FALSE; CheckDDECritOut; EnterDDECrit; pcii = ValidateInstance((HANDLE)LongToHandle( idInst )); if (pcii == NULL) { BestSetLastDDEMLError(DMLERR_INVALIDPARAMETER); goto Exit; } /* * If this thread is in the middle of a synchronous transaction or * a callback, we need to back out of those first. */ if ((pcii->flags & IIF_IN_SYNC_XACT) || pcii->cInDDEMLCallback) { pcii->afCmd |= APPCMD_UNINIT_ASAP; fRet = TRUE; goto Exit; } ApplyFunctionToObjects(HTYPE_CONVERSATION_LIST, InstFromHandle(pcii->hInstClient), (PFNHANDLEAPPLY)DdeDisconnectList); ApplyFunctionToObjects(HTYPE_CLIENT_CONVERSATION, InstFromHandle(pcii->hInstClient), (PFNHANDLEAPPLY)DdeDisconnect); ApplyFunctionToObjects(HTYPE_SERVER_CONVERSATION, InstFromHandle(pcii->hInstClient), (PFNHANDLEAPPLY)DdeDisconnect); ApplyFunctionToObjects(HTYPE_ZOMBIE_CONVERSATION, InstFromHandle(pcii->hInstClient), (PFNHANDLEAPPLY)WaitForZombieTerminate); ApplyFunctionToObjects(HTYPE_DATA_HANDLE, InstFromHandle(pcii->hInstClient), (PFNHANDLEAPPLY)ApplyFreeDataHandle); LeaveDDECrit; NtUserCallOneParam((ULONG_PTR)pcii->hInstServer, SFI__CSDDEUNINITIALIZE); NtUserDestroyWindow(pcii->hwndMother); EnterDDECrit; DDEMLFree(pcii->plaNameService); DestroyInstance(pcii->hInstClient); // unlink pcii from pciiList if (pciiList == pcii) { pciiList = pciiList->next; } else { for (pciiPrev = pciiList; pciiPrev != NULL && pciiPrev->next != pcii; pciiPrev = pciiPrev->next) { ; } if (pciiPrev != NULL) { pciiPrev->next = pcii->next; } } DDEMLFree(pcii); fRet = TRUE; Exit: LeaveDDECrit; return (fRet); }
Geometry::~Geometry() { _shutdown(); DestroyInstance(); }
CVisualization::~CVisualization() { /* Destroy the class "kodi::addon::CInstanceVisualization" on add-on side */ DestroyInstance(); }
void RPG_GuiManager::OnDeactivate() { DestroyInstance(); }
World::~World() { DestroyInstance(); }
CVFSEntry::~CVFSEntry() { DestroyInstance(); }
/* - return the right instance for the object, based on its InstanceId - create the instance if it's not created already - the player is not actually added to the instance (only in InstanceMap::Add) */ Map* MapInstanced::CreateInstanceForPlayer(const uint32 mapId, Player* player) { if (GetId() != mapId || !player) return NULL; Map* map = NULL; if (IsBattlegroundOrArena()) { // instantiate or find existing bg map for player // the instance id is set in battlegroundid uint32 newInstanceId = player->GetBattlegroundId(); if (!newInstanceId) return NULL; map = sMapMgr->FindMap(mapId, newInstanceId); if (!map) { Battleground* bg = player->GetBattleground(true); if (bg && bg->GetStatus() < STATUS_WAIT_LEAVE) map = CreateBattleground(newInstanceId, bg); else { player->TeleportToEntryPoint(); return NULL; } } } else { Difficulty realdiff = player->GetDifficulty(IsRaid()); uint32 destInstId = sInstanceSaveMgr->PlayerGetDestinationInstanceId(player, GetId(), realdiff); if (destInstId) { InstanceSave* pSave = sInstanceSaveMgr->GetInstanceSave(destInstId); ASSERT(pSave); // pussywizard: must exist map = FindInstanceMap(destInstId); if (!map) map = CreateInstance(destInstId, pSave, realdiff); else if ((mapId == 631 || mapId == 724) && !map->HavePlayers() && map->GetDifficulty() != realdiff) { if (player->isBeingLoaded()) // pussywizard: crashfix (assert(passengers.empty) fail in ~transport), could be added to a transport during loading from db return NULL; if (!map->AllTransportsEmpty()) map->AllTransportsRemovePassengers(); // pussywizard: gameobjects / summons (assert(passengers.empty) fail in ~transport) for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i) if (i->first == destInstId) { DestroyInstance(i); map = CreateInstance(destInstId, pSave, realdiff); break; } } } else { uint32 newInstanceId = sMapMgr->GenerateInstanceId(); ASSERT(!FindInstanceMap(newInstanceId)); // pussywizard: instance with new id can't exist Difficulty diff = player->GetGroup() ? player->GetGroup()->GetDifficulty(IsRaid()) : player->GetDifficulty(IsRaid()); map = CreateInstance(newInstanceId, NULL, diff); } } return map; }
// static XPCNativeSet* XPCNativeSet::GetNewOrUsed(XPCCallContext& ccx, nsIClassInfo* classInfo) { AutoMarkingNativeSetPtr set(ccx); XPCJSRuntime* rt = ccx.GetRuntime(); ClassInfo2NativeSetMap* map = rt->GetClassInfo2NativeSetMap(); if (!map) return nsnull; { // scoped lock XPCAutoLock lock(rt->GetMapLock()); set = map->Find(classInfo); } if (set) return set; nsIID** iidArray = nsnull; AutoMarkingNativeInterfacePtrArrayPtr interfaceArray(ccx); PRUint32 iidCount = 0; if (NS_FAILED(classInfo->GetInterfaces(&iidCount, &iidArray))) { // Note: I'm making it OK for this call to fail so that one can add // nsIClassInfo to classes implemented in script without requiring this // method to be implemented. // Make sure these are set correctly... iidArray = nsnull; iidCount = 0; } NS_ASSERTION((iidCount && iidArray) || !(iidCount || iidArray), "GetInterfaces returned bad array"); // !!! from here on we only exit through the 'out' label !!! if (iidCount) { AutoMarkingNativeInterfacePtrArrayPtr arr(ccx, new XPCNativeInterface*[iidCount], iidCount, true); if (!arr) goto out; interfaceArray = arr; XPCNativeInterface** currentInterface = interfaceArray; nsIID** currentIID = iidArray; PRUint16 interfaceCount = 0; for (PRUint32 i = 0; i < iidCount; i++) { nsIID* iid = *(currentIID++); if (!iid) { NS_ERROR("Null found in classinfo interface list"); continue; } XPCNativeInterface* iface = XPCNativeInterface::GetNewOrUsed(ccx, iid); if (!iface) { // XXX warn here continue; } *(currentInterface++) = iface; interfaceCount++; } if (interfaceCount) { set = NewInstance(ccx, interfaceArray, interfaceCount); if (set) { NativeSetMap* map2 = rt->GetNativeSetMap(); if (!map2) goto out; XPCNativeSetKey key(set, nsnull, 0); { // scoped lock XPCAutoLock lock(rt->GetMapLock()); XPCNativeSet* set2 = map2->Add(&key, set); if (!set2) { NS_ERROR("failed to add our set!"); DestroyInstance(set); set = nsnull; goto out; } if (set2 != set) { DestroyInstance(set); set = set2; } } } } else set = GetNewOrUsed(ccx, &NS_GET_IID(nsISupports)); } else set = GetNewOrUsed(ccx, &NS_GET_IID(nsISupports)); if (set) { // scoped lock XPCAutoLock lock(rt->GetMapLock()); #ifdef DEBUG XPCNativeSet* set2 = #endif map->Add(classInfo, set); NS_ASSERTION(set2, "failed to add our set!"); NS_ASSERTION(set2 == set, "hashtables inconsistent!"); } out: if (iidArray) NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(iidCount, iidArray); if (interfaceArray) delete [] interfaceArray.get(); return set; }
AIManager::~AIManager() { DestroyInstance(); }
CScreenSaver::~CScreenSaver() { /* Destroy the class "kodi::addon::CInstanceScreensaver" on add-on side */ DestroyInstance(); }
bool GameFactory::DestroyInstance(NetworkID id) { FactoryObject reference = GetObject(id); DestroyInstance(reference); return true; }