[PATCH] Support: Provide a function to get the home directory of an arbitrary user
Reid Kleckner
rnk at google.com
Thu Jul 31 18:07:22 PDT 2014
================
Comment at: lib/Support/Unix/Path.inc:683
@@ +682,3 @@
+ result.clear();
+ struct passwd *user_entry = ::getpwnam (user.c_str());
+ if (user_entry == nullptr)
----------------
StringRef doesn't have a c_str() method, but you can do .str().c_str() to convert to std::string first. *yawn*, excessive copies in C++. :(
================
Comment at: lib/Support/Windows/Path.inc:880-882
@@ +879,5 @@
+ char* string_sid = nullptr;
+ std::string reg_path;
+ std::vector<char> buffer;
+ std::vector<char> domain_buffer;
+ HKEY hkey = nullptr;
----------------
I'd sink these declarations to the point of first use.
================
Comment at: lib/Support/Windows/Path.inc:886
@@ +885,3 @@
+
+ ::LookupAccountName(nullptr, user.data(), sid, &sid_size, nullptr, &cch_referenced_domain, &sid_name_use);
+ if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
----------------
there's a bunch of micro 80cols stuff that clang-format can fix here.
================
Comment at: lib/Support/Windows/Path.inc:905
@@ +904,3 @@
+
+ buffer.resize(cbData);
+ uint8_t* buf_data = reinterpret_cast<uint8_t*>(buffer.data());
----------------
Can we avoid the copy by resizing result directly and passing it into the query?
http://reviews.llvm.org/D4749
More information about the llvm-commits
mailing list