aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/runtime.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/runtime/runtime.c')
-rw-r--r--src/pkg/runtime/runtime.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/pkg/runtime/runtime.c b/src/pkg/runtime/runtime.c
index dbdc0f2ac6..9d3efe966d 100644
--- a/src/pkg/runtime/runtime.c
+++ b/src/pkg/runtime/runtime.c
@@ -152,34 +152,36 @@ int32 runtime·isplan9;
void
runtime·goargs(void)
{
- String *gargv;
- String *genvv;
- int32 i, envc;
+ String *s;
+ int32 i;
// for windows implementation see "os" package
if(Windows)
return;
- if(runtime·isplan9)
- envc=0;
- else
- for(envc=0; argv[argc+1+envc] != 0; envc++)
- ;
-
- gargv = runtime·malloc(argc*sizeof gargv[0]);
- genvv = runtime·malloc(envc*sizeof genvv[0]);
-
+ s = runtime·malloc(argc*sizeof s[0]);
for(i=0; i<argc; i++)
- gargv[i] = runtime·gostringnocopy(argv[i]);
- os·Args.array = (byte*)gargv;
+ s[i] = runtime·gostringnocopy(argv[i]);
+ os·Args.array = (byte*)s;
os·Args.len = argc;
os·Args.cap = argc;
+}
+
+void
+runtime·goenvs_unix(void)
+{
+ String *s;
+ int32 i, n;
+
+ for(n=0; argv[argc+1+n] != 0; n++)
+ ;
- for(i=0; i<envc; i++)
- genvv[i] = runtime·gostringnocopy(argv[argc+1+i]);
- os·Envs.array = (byte*)genvv;
- os·Envs.len = envc;
- os·Envs.cap = envc;
+ s = runtime·malloc(n*sizeof s[0]);
+ for(i=0; i<n; i++)
+ s[i] = runtime·gostringnocopy(argv[argc+1+i]);
+ os·Envs.array = (byte*)s;
+ os·Envs.len = n;
+ os·Envs.cap = n;
}
// Atomic add and return new value.