Store RcFile pointers, rather than inline objects.
Since RcFile hands out pointers to its string members, modifying
vector<RcFile> may cause reallocation, which invalidates handed out
pointers.
Fixes #205.
--
Change-Id: Id4eb0a4e8a52373130140f1de5697f4e4f4a6f95
Reviewed-on: https://bazel-review.googlesource.com/#/c/1360/
MOS_MIGRATED_REVID=94276823
diff --git a/src/main/cpp/option_processor.h b/src/main/cpp/option_processor.h
index 15724e8..5b12bcd 100644
--- a/src/main/cpp/option_processor.h
+++ b/src/main/cpp/option_processor.h
@@ -35,7 +35,7 @@
public:
OptionProcessor();
- virtual ~OptionProcessor() {}
+ virtual ~OptionProcessor();
// Parse a command line and the appropriate blazerc files. This should be
// invoked only once per OptionProcessor object.
@@ -87,7 +87,7 @@
public:
RcFile(const string& filename, int index);
blaze_exit_code::ExitCode Parse(
- std::vector<RcFile>* rcfiles,
+ std::vector<RcFile*>* rcfiles,
std::map<string, std::vector<RcOption> >* rcoptions,
string* error);
const string& Filename() const { return filename_; }
@@ -96,7 +96,7 @@
private:
static blaze_exit_code::ExitCode Parse(const string& filename,
const int index,
- std::vector<RcFile>* rcfiles,
+ std::vector<RcFile*>* rcfiles,
std::map<string,
std::vector<RcOption> >* rcoptions,
std::list<string>* import_stack,
@@ -109,7 +109,7 @@
void AddRcfileArgsAndOptions(bool batch, const string& cwd);
blaze_exit_code::ExitCode ParseStartupOptions(string *error);
- std::vector<RcFile> blazercs_;
+ std::vector<RcFile*> blazercs_;
std::map<string, std::vector<RcOption> > rcoptions_;
std::vector<string> args_;
unsigned int startup_args_;