Index: runtime/bin/platform_linux.cc |
diff --git a/runtime/bin/platform_linux.cc b/runtime/bin/platform_linux.cc |
index 8b114c62cca47ada1769594e92d18803af1b3827..495644f385604603472dd1caf0b3a8ddc45b31c4 100644 |
--- a/runtime/bin/platform_linux.cc |
+++ b/runtime/bin/platform_linux.cc |
@@ -1,4 +1,4 @@ |
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
// for details. All rights reserved. Use of this source code is governed by a |
// BSD-style license that can be found in the LICENSE file. |
@@ -39,6 +39,21 @@ bool Platform::LocalHostname(char *buffer, intptr_t buffer_length) { |
} |
+char** Platform::Environment(intptr_t* count) { |
+ // Using environ directly is only safe as long as we do not |
+ // provide access to modifying environment variables. |
+ intptr_t i = 0; |
Søren Gjesse
2012/04/17 16:10:47
Why add i? Maybe just use *count instead.
Mads Ager (google)
2012/04/17 16:20:14
I wanted to have on clear assignment to count. Als
|
+ char** tmp = environ; |
+ while (*(tmp++) != NULL) i++; |
+ *count = i; |
+ char** result = new char*[i]; |
+ for (intptr_t current = 0; current < i; current++) { |
+ result[current] = environ[current]; |
+ } |
+ return result; |
+} |
+ |
+ |
char* Platform::StrError(int error_code) { |
static const int kBufferSize = 1024; |
char* error = static_cast<char*>(malloc(kBufferSize)); |