diff options
author | Steve Bennett <steveb@workware.net.au> | 2010-09-10 15:22:26 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2010-10-15 11:02:52 +1000 |
commit | 82594fa49fcc6a10cd020dda214688fda215605e (patch) | |
tree | 881462a91cf38fc4007878d08b6f5dfa4c8ed953 /jim-posix.c | |
parent | ec978d041463c9effdb17018f064df29592f8d40 (diff) | |
download | jimtcl-82594fa49fcc6a10cd020dda214688fda215605e.zip jimtcl-82594fa49fcc6a10cd020dda214688fda215605e.tar.gz jimtcl-82594fa49fcc6a10cd020dda214688fda215605e.tar.bz2 |
Reduce excessive stack usage
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim-posix.c')
-rw-r--r-- | jim-posix.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/jim-posix.c b/jim-posix.c index 61f5af8..1013121 100644 --- a/jim-posix.c +++ b/jim-posix.c @@ -162,18 +162,22 @@ static int Jim_PosixGetidsCommand(Jim_Interp *interp, int argc, Jim_Obj *const * #define JIM_HOST_NAME_MAX 1024 static int Jim_PosixGethostnameCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { - char buf[JIM_HOST_NAME_MAX]; + char *buf; + int rc = JIM_OK; if (argc != 1) { Jim_WrongNumArgs(interp, 1, argv, ""); return JIM_ERR; } + buf = Jim_Alloc(JIM_HOST_NAME_MAX); if (gethostname(buf, JIM_HOST_NAME_MAX) == -1) { Jim_PosixSetError(interp); - return JIM_ERR; + rc = JIM_ERR; } - Jim_SetResultString(interp, buf, -1); - return JIM_OK; + else { + Jim_SetResult(interp, Jim_NewStringObjNoAlloc(interp, buf, -1)); + } + return rc; } static int Jim_PosixUptimeCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv) |