* lib/xgethostname.c (xgethostname): Shrink the hostname buffer before
returning it.
+2019-07-05 Bruno Haible <bruno@clisp.org>
+
+ xgethostname: Don't return an excessive memory allocation.
+ * lib/xgethostname.c (xgethostname): Shrink the hostname buffer before
+ returning it.
+
2019-07-05 Bruno Haible <bruno@clisp.org>
areadlinkat-with-size: Don't return an excessive memory allocation.
}
}
+ /* Shrink HOSTNAME before returning it. */
+ {
+ size_t actual_size = strlen (hostname) + 1;
+ if (actual_size < size)
+ {
+ char *shrinked_hostname = realloc (hostname, actual_size);
+ if (shrinked_hostname != NULL)
+ hostname = shrinked_hostname;
+ }
+ }
+
return hostname;
}