This makes it easier to import xgethostname.c into an external program. 2009-08-29 Robert Millan <rmh....@aybabtu.com>
* lib/xgethostname.c: Remove `"xalloc.h"'. (xgethostname): Use realloc() instead of x2realloc(). -- Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
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 <errno.h> #include <unistd.h> -#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;