2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-11-09 14:50:58 +00:00

Further refactor QUtil::call_main_from_wmain

This commit is contained in:
m-holger 2024-05-17 10:31:50 +01:00
parent 602d5eb61d
commit 6f09069f43

View File

@ -1910,14 +1910,14 @@ call_main_from_wmain(
} }
utf8_argv.emplace_back(QUtil::utf16_to_utf8(utf16)); utf8_argv.emplace_back(QUtil::utf16_to_utf8(utf16));
} }
auto utf8_argv_sp = std::make_unique<char*[]>(1 + utf8_argv.size()); std::vector<char*> new_argv;
char** new_argv = utf8_argv_sp.get(); new_argv.reserve(utf8_argv.size() + 1U);
for (size_t i = 0; i < utf8_argv.size(); ++i) { for (auto const& arg: utf8_argv) {
new_argv[i] = utf8_argv.at(i).data(); new_argv.emplace_back(const_cast<char*>(arg.data()));
} }
argc = QIntC::to_int(utf8_argv.size()); argc = QIntC::to_int(utf8_argv.size());
new_argv[argc] = nullptr; new_argv.emplace_back(nullptr);
return realmain(argc, new_argv); return realmain(argc, new_argv.data());
} }
int int