Commit 602d5eb61dfc51078aaeb086f956b500cd4a46af

Authored by m-holger
1 parent 7f8e0a0d

Refactor QUtil::call_main_from_wmain

Showing 1 changed file with 4 additions and 4 deletions
libqpdf/QUtil.cc
... ... @@ -1899,7 +1899,8 @@ call_main_from_wmain(
1899 1899 // strings for compatibility with other systems. That way the rest of qpdf.cc can just act like
1900 1900 // arguments are UTF-8.
1901 1901  
1902   - std::vector<std::unique_ptr<char[]>> utf8_argv;
  1902 + std::vector<std::string> utf8_argv;
  1903 + utf8_argv.reserve(QIntC::to_size(argc));
1903 1904 for (int i = 0; i < argc; ++i) {
1904 1905 std::string utf16;
1905 1906 for (size_t j = 0; j < std::wcslen(argv[i]); ++j) {
... ... @@ -1907,13 +1908,12 @@ call_main_from_wmain(
1907 1908 utf16.append(1, static_cast<char>(QIntC::to_uchar(codepoint >> 8)));
1908 1909 utf16.append(1, static_cast<char>(QIntC::to_uchar(codepoint & 0xff)));
1909 1910 }
1910   - std::string utf8 = QUtil::utf16_to_utf8(utf16);
1911   - utf8_argv.push_back(QUtil::make_unique_cstr(utf8));
  1911 + utf8_argv.emplace_back(QUtil::utf16_to_utf8(utf16));
1912 1912 }
1913 1913 auto utf8_argv_sp = std::make_unique<char*[]>(1 + utf8_argv.size());
1914 1914 char** new_argv = utf8_argv_sp.get();
1915 1915 for (size_t i = 0; i < utf8_argv.size(); ++i) {
1916   - new_argv[i] = utf8_argv.at(i).get();
  1916 + new_argv[i] = utf8_argv.at(i).data();
1917 1917 }
1918 1918 argc = QIntC::to_int(utf8_argv.size());
1919 1919 new_argv[argc] = nullptr;
... ...