X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fxgethostname.c;h=216e78be49b082318b15c228b44e7f29cd1b9143;hb=9730c386c1eb4450d04fa75037dab61e41038919;hp=86408e775d8b1eb310b3a869b70e48a0f5639241;hpb=cba9751a5c129f78d162fbe541a2f50ea1753e93;p=gnulib.git diff --git a/lib/xgethostname.c b/lib/xgethostname.c index 86408e775..216e78be4 100644 --- a/lib/xgethostname.c +++ b/lib/xgethostname.c @@ -18,14 +18,7 @@ /* Written by Jim Meyering, meyering@comco.com */ #ifdef HAVE_CONFIG_H -#if defined (CONFIG_BROKETS) -/* We use instead of "config.h" so that a compilation - using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h - (which it would do because it found this file in $srcdir). */ #include -#else -#include "config.h" -#endif #endif #include @@ -46,12 +39,12 @@ xgethostname () 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);