Fix adding items to the argument map.

This commit is contained in:
Relintai 2022-04-28 22:59:05 +02:00
parent 131d4b49cc
commit 17a2780b28

View File

@ -49,7 +49,7 @@ void ArgParser::post_process_args() {
if (main_arg) {
main_arg = false;
arguments_set.insert(arg_main_command);
arguments_map[arg_main_command] = &arg_command;
arguments_map[arg_main_command] = new String(arg_command);
} else {
arguments_set.insert(arg_command);
}
@ -75,4 +75,13 @@ String *ArgParser::get_value(const String &arg) {
ArgParser::ArgParser() {
}
ArgParser::~ArgParser() {
for (std::map<String, String *>::iterator it = arguments_map.begin(); it != arguments_map.end(); it++) {
String *s = it->second;
if (s) {
delete s;
}
}
arguments_map.clear();
}