================
@@ -83,6 +76,45 @@ GetFlattenedWindowsCommandStringW(Args args) {
   return llvm::sys::flattenWindowsCommandLine(args_ref);
 }
 
+llvm::ErrorOr<std::wstring> GetFlattenedWindowsCommandStringW(char *args[]) {
+  std::vector<llvm::StringRef> args_ref;
+  for (int i = 0; args[i] != nullptr; ++i) {
+    args_ref.push_back(args[i]);
+  }
+
+  return llvm::sys::flattenWindowsCommandLine(args_ref);
+}
+
+llvm::ErrorOr<llvm::scope_exit<std::function<void()>>>
+SetupProcThreadAttributeList(STARTUPINFOEXW &startupinfoex) {
+  SIZE_T attributelist_size = 0;
+  InitializeProcThreadAttributeList(/*lpAttributeList=*/nullptr,
+                                    /*dwAttributeCount=*/1, /*dwFlags=*/0,
+                                    &attributelist_size);
+
+  startupinfoex.lpAttributeList =
+      static_cast<LPPROC_THREAD_ATTRIBUTE_LIST>(malloc(attributelist_size));
+
+  if (!startupinfoex.lpAttributeList)
+    return llvm::mapWindowsError(ERROR_OUTOFMEMORY);
+
+  auto cleanup = llvm::scope_exit<std::function<void()>>([&startupinfoex] {
----------------
ashgti wrote:

Nit: I find it a bit odd to return a `llvm::scope_exit`, those usually don't 
leave where they were defined and I would expect the caller to be the one in 
charge of this.

Can return the cleanup function instead? Or lift his into an object and have 
the destructor cleanup once its no longer needed?

https://github.com/llvm/llvm-project/pull/174635
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to