Merge "Do not expose namespace vector" am: 2c9326fd9b am: b8d01f4cbf
am: 235b520dfb
Change-Id: Ia812dbac0ad2f6e113bbadb5f0c8c2d0d35139c1
diff --git a/contents/common/system_links.cc b/contents/common/system_links.cc
index c98fbb7..27ba013 100644
--- a/contents/common/system_links.cc
+++ b/contents/common/system_links.cc
@@ -30,18 +30,16 @@
void AddStandardSystemLinks(const Context& ctx, Section* section) {
std::string system_ns_name = ctx.GetSystemNamespaceName();
- Namespace* system_ns = section->GetNamespace(system_ns_name);
- for (Namespace& ns : section->GetNamespaces()) {
- if (&ns != system_ns) {
+ section->ForEachNamespaces([system_ns_name](Namespace& ns) {
+ if (ns.GetName() != system_ns_name) {
ns.GetLink(system_ns_name)
.AddSharedLib({"libc.so",
"libm.so",
"libdl.so",
"@{SANITIZER_RUNTIME_LIBRARIES}"});
}
- }
+ });
}
-
} // namespace contents
} // namespace linkerconfig
} // namespace android
diff --git a/modules/include/linkerconfig/section.h b/modules/include/linkerconfig/section.h
index 0d1179f..4d9aee3 100644
--- a/modules/include/linkerconfig/section.h
+++ b/modules/include/linkerconfig/section.h
@@ -40,13 +40,15 @@
std::vector<std::string> GetBinaryPaths();
std::string GetName();
- // Use for iteration only.
- std::vector<Namespace>& GetNamespaces() {
- return namespaces_;
- }
-
Namespace* GetNamespace(const std::string& namespace_name);
+ template <class _Function>
+ void ForEachNamespaces(_Function f) {
+ for (auto& ns : namespaces_) {
+ f(ns);
+ }
+ }
+
private:
const std::string name_;
std::vector<Namespace> namespaces_;