From da91b29ed281126c7c3741dfb8fdb2f8c4b04142 Mon Sep 17 00:00:00 2001 From: mccallum Date: Mon, 8 Jan 1996 17:05:45 +0000 Subject: [PATCH] (_GNU_MAX_HOST_NAMELEN): Macro removed; using MAXHOSTNAMELEN from instead. All users changed. (_gnu_process_args): Malloc and fill NSArgv; assignment of char** from *char[] isn't right. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@692 72102866-910b-0410-8b05-ffd578937521 --- Source/NSProcessInfo.m | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/Source/NSProcessInfo.m b/Source/NSProcessInfo.m index 66dad36a2..103bddc25 100644 --- a/Source/NSProcessInfo.m +++ b/Source/NSProcessInfo.m @@ -52,6 +52,8 @@ * - To the NEXTSTEP/GNUStep community *************************************************************************/ +#include /* for MAXHOSTNAMELEN */ + #ifdef NeXT #ifdef SCITOOLS #import @@ -79,13 +81,6 @@ #include #endif /* NeXT */ - - -/* This is the longest max host name allowed for all different systems - * I had a chance to read the man pages. - */ -#define _GNU_MAX_HOST_NAMELEN 256 - /* This error message should be called only if the private main function * was not executed successfully. This may heppen ONLY if onother library * or kit defines its own main function (as libobjects does). @@ -153,11 +148,13 @@ const char **NSArgv; *************************************************************************/ static void -_gnu_process_args(int argc, char **argv, char *env[]) +_gnu_process_args(int argc, char *argv[], char *env[]) { int i; - NSArgv = argv; + OBJC_MALLOC(NSArgv, const char*, argc); + for (i = 0; i < argc; i++) + NSArgv[i] = argv[i]; /* Getting the process name */ _gnu_processName = [[NSString alloc] initWithCString:argv[0]]; @@ -327,9 +324,9 @@ int main(int argc, char *argv[], char *env[]) { if (!_gnu_hostName) { - char hn[_GNU_MAX_HOST_NAMELEN]; + char hn[MAXHOSTNAMELEN]; - gethostname(hn, _GNU_MAX_HOST_NAMELEN); + gethostname(hn, MAXHOSTNAMELEN); _gnu_hostName = [[NSString alloc] initWithCString:hn]; } return _gnu_hostName;