Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1602)

Unified Diff: runtime/bin/platform_linux.cc

Issue 10112002: Add read-only environment variable access. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add windows error handling. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/platform_impl.dart ('k') | runtime/bin/platform_macos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
« no previous file with comments | « runtime/bin/platform_impl.dart ('k') | runtime/bin/platform_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698