Reserve space in the char backing vector to prevent reallocations
The pointers in image_filenames_ and oat_filenames can become invalidated
if the char_backing_storage_ vector gets reallocated when adding strings.
Test: mma test-art-host-gtest-dex2oat_test
Change-Id: I82714468163ce49ce53953e6edcb57a17d46cdbb
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 5d44cc1..1ddf961 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -990,6 +990,8 @@
}
}
+ char_backing_storage_.reserve((dex_locations_.size() - 1) * 2);
+
// Now create the other names. Use a counted loop to skip the first one.
for (size_t i = 1; i < dex_locations_.size(); ++i) {
// TODO: Make everything properly std::string.