BOOL CNdasLogicalDeviceManager::Unregister(CNdasUnitDevice& unitDevice) { ximeta::CAutoLock autolock(this); CRefObjPtr<CNdasLogicalDevice> pLogDevice = unitDevice.GetLogicalDevice(); if (NULL == pLogDevice.p) { return FALSE; } DWORD ldSequence = unitDevice.GetLDSequence(); pLogDevice->RemoveUnitDevice(unitDevice); if (pLogDevice->GetUnitDeviceInstanceCount() == 0) { NDAS_LOGICALDEVICE_ID id = pLogDevice->GetLogicalDeviceId(); LDGroupMap::size_type ldg_erased = m_LDGroupMap.erase(pLogDevice->GetLDGroup()); _ASSERTE(1 == ldg_erased); LDIDMap::size_type id_erased = m_LDIDMap.erase(id); _ASSERTE(1 == id_erased); pLogDevice->Release(); BOOL fSuccess = cpDeallocateID(id); _ASSERTE(fSuccess); } return TRUE; }