void ModuleList::ReplaceEquivalent (const ModuleSP &module_sp) { if (module_sp) { Mutex::Locker locker(m_modules_mutex); // First remove any equivalent modules. Equivalent modules are modules // whose path, platform path and architecture match. ModuleSpec equivalent_module_spec (module_sp->GetFileSpec(), module_sp->GetArchitecture()); equivalent_module_spec.GetPlatformFileSpec() = module_sp->GetPlatformFileSpec(); size_t idx = 0; while (idx < m_modules.size()) { ModuleSP module_sp (m_modules[idx]); if (module_sp->MatchesModuleSpec (equivalent_module_spec)) RemoveImpl(m_modules.begin() + idx); else ++idx; } // Now add the new module to the list Append(module_sp); } }
//-------------------------------------------------------------- /// Unary predicate function object callback. //-------------------------------------------------------------- bool operator () (const ModuleSP& module_sp) const { if (m_file_spec_ptr) { if (m_file_spec_is_platform) { if (!FileSpec::Equal (*m_file_spec_ptr, module_sp->GetPlatformFileSpec(), m_file_spec_compare_basename_only)) return false; } else { if (!FileSpec::Equal (*m_file_spec_ptr, module_sp->GetFileSpec(), m_file_spec_compare_basename_only)) return false; } } if (m_arch_ptr && m_arch_ptr->IsValid()) { if (module_sp->GetArchitecture() != *m_arch_ptr) return false; } if (m_uuid_ptr && m_uuid_ptr->IsValid()) { if (module_sp->GetUUID() != *m_uuid_ptr) return false; } if (m_object_name) { if (module_sp->GetObjectName() != *m_object_name) return false; } return true; }