changeset 19912:5054f82cbd50

GNU shell utilities
author Jim Meyering <jim@meyering.net>
date Thu, 19 May 1994 22:18:30 +0000
parents c3709a4fa4eb
children 0b6f22b0f348
files lib/xgethostname.c
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lib/xgethostname.c	Fri May 13 15:46:11 1994 +0000
+++ b/lib/xgethostname.c	Thu May 19 22:18:30 1994 +0000
@@ -46,12 +46,12 @@
   int err;
 
   size = INITIAL_HOSTNAME_LENGTH;
+  hostname = xmalloc (size);
   while (1)
     {
-      hostname = xmalloc (size);
       hostname[size - 1] = '\0';
       err = gethostname (hostname, size);
-      if (err || hostname[size - 1] == '\0')
+      if (err == 0 && hostname[size - 1] == '\0')
 	break;
       size *= 2;
       hostname = xrealloc (hostname, size);