From 82594fa49fcc6a10cd020dda214688fda215605e Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Fri, 10 Sep 2010 15:22:26 +1000 Subject: Reduce excessive stack usage Signed-off-by: Steve Bennett --- jim-posix.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'jim-posix.c') 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) -- cgit v1.1