diff --git a/lib/xgethostname.c b/lib/xgethostname.c index 875d497..1792908 100644 --- a/lib/xgethostname.c +++ b/lib/xgethostname.c @@ -27,8 +27,6 @@ #include #include -#include "xalloc.h" - #ifndef ENAMETOOLONG # define ENAMETOOLONG 0 #endif @@ -43,7 +41,7 @@ char * xgethostname (void) { - char *hostname = NULL; + char *hostname = NULL, *tmp; size_t size = INITIAL_HOSTNAME_LENGTH; while (1) @@ -53,7 +51,13 @@ xgethostname (void) even when the name is as long as the supplied buffer. */ size_t size_1; - hostname = x2realloc (hostname, &size); + tmp = realloc (hostname, size); + if (! tmp) + { + perror ("realloc"); + exit (1); + } + hostname = tmp; size_1 = size - 1; hostname[size_1 - 1] = '\0'; errno = 0;