| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/globals.h" | 5 #include "platform/globals.h" |
| 6 #if defined(TARGET_OS_WINDOWS) | 6 #if defined(TARGET_OS_WINDOWS) |
| 7 | 7 |
| 8 #include <process.h> // NOLINT | 8 #include <process.h> // NOLINT |
| 9 | 9 |
| 10 #include "bin/builtin.h" | 10 #include "bin/builtin.h" |
| 11 #include "bin/dartutils.h" |
| 11 #include "bin/process.h" | 12 #include "bin/process.h" |
| 12 #include "bin/eventhandler.h" | 13 #include "bin/eventhandler.h" |
| 13 #include "bin/lockers.h" | 14 #include "bin/lockers.h" |
| 14 #include "bin/log.h" | 15 #include "bin/log.h" |
| 15 #include "bin/socket.h" | 16 #include "bin/socket.h" |
| 16 #include "bin/thread.h" | 17 #include "bin/thread.h" |
| 17 #include "bin/utils.h" | 18 #include "bin/utils.h" |
| 18 #include "bin/utils_win.h" | 19 #include "bin/utils_win.h" |
| 19 | 20 |
| 20 | 21 |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 remaining -= written; | 458 remaining -= written; |
| 458 ASSERT(remaining >= 0); | 459 ASSERT(remaining >= 0); |
| 459 for (int i = 0; i < arguments_length; i++) { | 460 for (int i = 0; i < arguments_length; i++) { |
| 460 written = | 461 written = |
| 461 _snwprintf( | 462 _snwprintf( |
| 462 command_line_ + len, remaining, L" %s", system_arguments[i]); | 463 command_line_ + len, remaining, L" %s", system_arguments[i]); |
| 463 len += written; | 464 len += written; |
| 464 remaining -= written; | 465 remaining -= written; |
| 465 ASSERT(remaining >= 0); | 466 ASSERT(remaining >= 0); |
| 466 } | 467 } |
| 467 free(const_cast<wchar_t*>(system_path)); | |
| 468 for (int i = 0; i < arguments_length; i++) free(system_arguments[i]); | |
| 469 delete[] system_arguments; | 468 delete[] system_arguments; |
| 470 | 469 |
| 471 // Create environment block if an environment is supplied. | 470 // Create environment block if an environment is supplied. |
| 472 environment_block_ = NULL; | 471 environment_block_ = NULL; |
| 473 if (environment != NULL) { | 472 if (environment != NULL) { |
| 474 wchar_t** system_environment = new wchar_t*[environment_length]; | 473 wchar_t** system_environment = new wchar_t*[environment_length]; |
| 475 // Convert environment strings to system strings. | 474 // Convert environment strings to system strings. |
| 476 for (intptr_t i = 0; i < environment_length; i++) { | 475 for (intptr_t i = 0; i < environment_length; i++) { |
| 477 system_environment[i] = StringUtilsWin::Utf8ToWide(environment[i]); | 476 system_environment[i] = StringUtilsWin::Utf8ToWide(environment[i]); |
| 478 } | 477 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 491 len, | 490 len, |
| 492 L"%s", | 491 L"%s", |
| 493 system_environment[i]); | 492 system_environment[i]); |
| 494 ASSERT(result == len); | 493 ASSERT(result == len); |
| 495 block_index += len; | 494 block_index += len; |
| 496 environment_block_[block_index++] = '\0'; | 495 environment_block_[block_index++] = '\0'; |
| 497 } | 496 } |
| 498 // Block-terminating zero char. | 497 // Block-terminating zero char. |
| 499 environment_block_[block_index++] = '\0'; | 498 environment_block_[block_index++] = '\0'; |
| 500 ASSERT(block_index == block_size); | 499 ASSERT(block_index == block_size); |
| 501 for (intptr_t i = 0; i < environment_length; i++) { | |
| 502 free(system_environment[i]); | |
| 503 } | |
| 504 delete[] system_environment; | 500 delete[] system_environment; |
| 505 } | 501 } |
| 506 | 502 |
| 507 system_working_directory_ = NULL; | 503 system_working_directory_ = NULL; |
| 508 if (working_directory_ != NULL) { | 504 if (working_directory_ != NULL) { |
| 509 system_working_directory_ = | 505 system_working_directory_ = |
| 510 StringUtilsWin::Utf8ToWide(working_directory_); | 506 StringUtilsWin::Utf8ToWide(working_directory_); |
| 511 } | 507 } |
| 512 | 508 |
| 513 attribute_list_ = NULL; | 509 attribute_list_ = NULL; |
| 514 } | 510 } |
| 515 | 511 |
| 516 | 512 |
| 517 ~ProcessStarter() { | 513 ~ProcessStarter() { |
| 518 // Deallocate command-line and environment block strings. | 514 // Deallocate command-line and environment block strings. |
| 519 delete[] command_line_; | 515 delete[] command_line_; |
| 520 delete[] environment_block_; | 516 delete[] environment_block_; |
| 521 if (system_working_directory_ != NULL) { | |
| 522 free(const_cast<wchar_t*>(system_working_directory_)); | |
| 523 } | |
| 524 if (attribute_list_ != NULL) { | 517 if (attribute_list_ != NULL) { |
| 525 delete_proc_thread_attr_list(attribute_list_); | 518 delete_proc_thread_attr_list(attribute_list_); |
| 526 free(attribute_list_); | 519 free(attribute_list_); |
| 527 } | 520 } |
| 528 } | 521 } |
| 529 | 522 |
| 530 | 523 |
| 531 int Start() { | 524 int Start() { |
| 532 // Create pipes required. | 525 // Create pipes required. |
| 533 int err = CreatePipes(); | 526 int err = CreatePipes(); |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 USE(SetConsoleCtrlHandler(SignalHandler, false)); | 1036 USE(SetConsoleCtrlHandler(SignalHandler, false)); |
| 1044 } | 1037 } |
| 1045 } | 1038 } |
| 1046 delete handler; | 1039 delete handler; |
| 1047 } | 1040 } |
| 1048 | 1041 |
| 1049 } // namespace bin | 1042 } // namespace bin |
| 1050 } // namespace dart | 1043 } // namespace dart |
| 1051 | 1044 |
| 1052 #endif // defined(TARGET_OS_WINDOWS) | 1045 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |